C#打造自己的实体生成器复习课程.docVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档