所以,实际上这个问题是我目前的基石.我正在努力重构我的个人项目,尝试提高性能,优化内存使用,使代码简单明了.我有一个不同的应用程序层(实际上,DAL,BLL,ServiceAgent是WCF服务).我使用实体/模型/ DTO在这些层之间传递数据,这是无状态的(根本没有任何逻辑).目前这是一个像这样的对象
public class Person
{
public ComplexId Id { get; set; }
public string Name { get; set; }
// ...
}
Run Code Online (Sandbox Code Playgroud)
我曾经使用这种方法,它就像是"最佳实践",是吗?这是存储传输数据的最佳方式吗?如果我为这样的结构更改它会怎么样:
public struct Peson
{
public ComplexIdentifier ComplexId;
public string Name;
}
public struct ComplexIdentifier
{
public int LocalId;
public int GlobalId;
}
Run Code Online (Sandbox Code Playgroud)
从性能/内存使用角度来看,这是更好的方法吗?或者也许有某种陷阱这样做?
我正在尝试填充包含2个具有一对多关系的表的DataSet.我正在使用DataReader来实现这个目的:
public DataSet SelectOne(int id)
{
DataSet result = new DataSet();
using (DbCommand command = Connection.CreateCommand())
{
command.CommandText = "select * from table1";
var param = ParametersBuilder.CreateByKey(command, "ID", id, null);
command.Parameters.Add(param);
Connection.Open();
using (DbDataReader reader = command.ExecuteReader())
{
result.MainTable.Load(reader);
}
Connection.Close();
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但我只填了一张桌子.我如何实现目标 - 填写两个表格?
如果可能的话,我想使用DataReader而不是DataAdapter.
我的情况是:
System.Guid) - 很难在MS Access上简单地实现和支持.此外,它对性能不利int或long int作为PK 会很好所以,我想:
int或希望long int 我目前的解决方案是从以下连接中获取CRC:
目前它适用于我,但也许有更好的方法来实现我的目标?您自己的任何评论,建议,示例或经验?
更新:客户端和服务器之间的同步是定期操作,因此每天可以发生2-3次(它的配置变量)
我正在尝试使用OpenXML框架在Excel电子表格中设置默认列宽,因此我的文件已损坏.这是代码
private void initSpreadsheetDocument()
{
// Add a WorkbookPart to the spreadsheet document.
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
var sheetData = new SheetData();
var properties = new SheetFormatProperties { DefaultColumnWidth = 25D };
Worksheet worksheet = new Worksheet();
worksheet.AppendChild(sheetData);
// here is line of code that corrupt file
// without it - file is being generated properly
worksheet.AppendChild(properties); ![enter image description here][1]
// Add a WorksheetPart to the WorkbookPart.
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = worksheet;
// …Run Code Online (Sandbox Code Playgroud) 这个问题是我之前的问题的延续.在没有涉及太多细节的情况下,我正在用2个相关的1对多表填充数据集.所以,我现在的问题是 - 为什么这段代码运作良好
public DataAgencyR_DataSet SelectOne(int id)
{
DataAgencyR_DataSet result = new DataAgencyR_DataSet();
using (DbCommand command = Connection.CreateCommand())
{
try
{
command.CommandText = SqlStrings.SelectDataAgencyR_SelectOne();
var param = ParametersBuilder.CreateByKey(command, "ID_DeclAgenc", id, "ID_DeclAgenc");
command.Parameters.Add(param);
Connection.Open();
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
System.Diagnostics.Trace.WriteLine(String.Format("{0}-{1}", reader[0], reader[1]));
}
System.Diagnostics.Trace.WriteLine("-------------");
reader.NextResult();
while (reader.Read())
{
System.Diagnostics.Trace.WriteLine(String.Format("{0}-{1}", reader[0], reader[1]));
}
}
}
catch (DbException e)
{
Logger.Error(e.Message, e);
throw new DataAccessException("Error occurs while SelectOne method porcessed", e);
}
finally
{
if (Connection.State != …Run Code Online (Sandbox Code Playgroud) 所以我正在尝试将 MiniProfiler ( https://github.com/MiniProfiler/dotnet ) 用于 WebForms 网站。我所做的是:
添加 <%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %> 语句
设置在 web.comfig
而且仍然 MiniProfiler 不起作用。简单的故障排除显示(在 Chrome 开发工具中)在该页面上我希望看到 MiniProfiler,我看到
http://localhost/mycoolsite/mini-profiler-resources/results 404.0 - 未找到
更多信息:我使用 .Net FW 4.5.1、IIS8 和 Intergated Mode(应用程序池)
任何想法可能对我有用?