有没有办法使用dapper-dot-net来使用属性来指定应该使用的列名而不是属性名?
public class Code
{
public int Id { get; set; }
public string Type { get; set; }
// This is called code in the table.
public string Value { get; set; }
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
无论我选择什么,我都希望能够命名我的房产.我们的数据库没有一致的命名约定.
如果没有小巧玲珑,还有其他类似的选择吗?
当我使用由第三方编写的.net提供程序时,我的应用程序池不断崩溃.我不知道在哪里开始解决这个问题.
我使用事件查看器来获取以下信息:
Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8 Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: 0x4ce7b96e Exception code: 0xc0000005 Fault offset: 0x00052d94 Faulting process id: 0x162c Faulting application start time: 0x01cd8ad4f6ad757b Faulting application path: c:\windows\system32\inetsrv\w3wp.exe Faulting module path: C:\windows\SYSTEM32\ntdll.dll Report Id: 36661c3b-f6c8-11e1-830c-180373c0a6cd
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2012-09-04T19:39:17.000000000Z" />
<EventRecordID>26328</EventRecordID>
<Channel>Application</Channel>
<Computer>my computer</Computer>
<Security />
</System>
<EventData>
<Data>w3wp.exe</Data>
<Data>7.5.7601.17514</Data>
<Data>4ce7a5f8</Data>
<Data>ntdll.dll</Data>
<Data>6.1.7601.17514</Data>
<Data>4ce7b96e</Data>
<Data>c0000005</Data>
<Data>00052d94</Data>
<Data>162c</Data>
<Data>01cd8ad4f6ad757b</Data>
<Data>c:\windows\system32\inetsrv\w3wp.exe</Data> …Run Code Online (Sandbox Code Playgroud) property.setvalue()有哪些替代方案?我读过它很慢.我用它来将IDataReader映射到POCO对象.
这是代码的截断版本.这里的一切对我来说都是新鲜的.我知道有很多框架可以完成这项任务.但是,我们不能使用它们.
public class DbAutoMapper<T>
{
public IEnumerable<T> MapToList(IDataReader reader)
{
var list = new List<T>();
while (reader.Read())
{
var obj = Activator.CreateInstance<T>();
foreach (PropertyInfo prop in obj.GetType().GetProperties())
{
foreach (var attribute in prop.GetCustomAttributes(true))
{
prop.SetValue(obj, value, null);
}
}
list.Add(obj);
}
return list;
}
}
Run Code Online (Sandbox Code Playgroud)