当前位置: 代码迷 >> .NET分析设计 >> 写了个Record类,求一下
  详细解决方案

写了个Record类,求一下

热度:223   发布时间:2016-05-01 22:44:54.0
写了个Record类,求高手指点一下!

public class Record<T>
        where T:class
    {
        private System.Collections.Generic.Dictionary<string, object> m_Record = null;

        private static readonly System.Collections.Generic.Dictionary<Entities.RecordMapping,System.Reflection.PropertyInfo> PatternRecordMappingList;

        static Record()
        {
            Record<T>.PatternRecordMappingList = new Dictionary<RecordMapping, System.Reflection.PropertyInfo>();
            Type PatternType = typeof(T);
            System.Reflection.PropertyInfo[] PatternTypeProperties = PatternType.GetProperties();
            foreach (var Item in PatternTypeProperties)
            {
                object[] Result = Item.GetCustomAttributes(true);
                foreach (var Mapping in Result)
                {
                    if (Mapping.GetType() == typeof(Entities.RecordMapping))
                        Record<T>.PatternRecordMappingList.Add(Mapping as Entities.RecordMapping,Item);
                }
            }
        }

        public Record(System.Data.IDataReader Reader)
        {
            this.Initialize(Reader);
        }

        protected void Initialize(System.Data.IDataReader Reader)
        {
            object c = Reader[0];
            this.m_Record = new Dictionary<string, object>(Reader.FieldCount);
            for (int Index = 0; Index < Reader.FieldCount; Index++)
            {
                this.m_Record.Add(Reader.GetName(Index), Reader[Index]);
            }
        }

        public T Entity()
        {
            Type EntityType = typeof(T);
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Dec 16 09:22:10 CST 2017
  • 最近登录:Sat Dec 16 09:22:10 CST 2017
  • 最近登录:Sat Dec 16 09:22:10 CST 2017
  • 最近登录:Sat Dec 16 09:22:10 CST 2017
  • 最近登录:Sat Dec 16 09:22:10 CST 2017