- 5
- 0
- 约2.54万字
- 约 21页
- 2020-04-19 发布于浙江
- 举报
C#打造自己的实体生成器
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Reflection;
/// summary
/// 实体阅读器类,可以从DataTable中或者DbDataReader的实例中将数据转换成对应的示例
/// 说明:(1)任何人都可以免费使用,请尽量保持此段说明。
/// (2)这个版本还不是最终版本,有任何意见或建议请到/zhoufoxcn处留言。
/// /summary
public sealed class EntityReader
{
private const BindingFlags BindingFlag = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
//将类型与该类型所有的可写且未被忽略属性之间建立映射
private static DictionaryType, Dictionarystring, PropertyInfo propertyMappings = new DictionaryType, Dictionarystring, PropertyInfo();
//存储NullableT与T的对应关系
private static DictionaryType, Type genericTypeMappings = new DictionaryType, Type();
static EntityReader()
{
genericTypeMappings.Add(typeof(Byte?), typeof(Byte));
genericTypeMappings.Add(typeof(SByte?), typeof(SByte));
genericTypeMappings.Add(typeof(Char?), typeof(Char));
genericTypeMappings.Add(typeof(Boolean?), typeof(Boolean));
genericTypeMappings.Add(typeof(Guid?), typeof(Guid));
genericTypeMappings.Add(typeof(Int16), typeof(Int16));
genericTypeMappings.Add(typeof(UInt16), typeof(UInt16));
genericTypeMappings.Add(typeof(Int32), typeof(Int32));
genericTypeMappings.Add(typeof(UInt32), typeof(UInt32));
genericTypeMappings.Add(typeof(Int64), typeof(Int64));
genericTypeMappings.Add(typeof(UInt64), typeof(UInt64));
genericTypeMappings.Add(typeof(Single), typeof(Single));
genericTypeMappings.Add(typeof(Double), typeof(Double));
genericTypeMappings.Add(typeof(Decimal), typeof(Decimal));
genericTypeMappings.Add(typeof(DateTime), typeof(DateTime));
genericTypeMappings.Add(typeof(TimeSpan), typeof
您可能关注的文档
最近下载
- 小学2026年学雷锋主题班会教学设计(5篇).docx VIP
- 特警理论考试题库及答案.doc VIP
- 新解读《GB_T 35644 - 2017地下管线数据获取规程》最新解读.docx VIP
- (PPT,3版)跨国公司经营与管理第一章 跨国公司总论.pptx VIP
- 学雷锋纪念日主题班会.pptx VIP
- 中心组“树立和践行正确政绩观”专题研讨发言提纲.docx VIP
- 沪科黔科版综合实践活动二下 天气预报 活动一《有用的天气预报》课件.ppt VIP
- 档案鉴定销毁审批表.docx VIP
- 电子烟危害教育主题班会.pptx VIP
- 2025年初级压缩机操作工(五级)技能认定理论考试题库资料(含答案).pdf
原创力文档

文档评论(0)