コード例 #1
0
ファイル: SQLSvrDb.cs プロジェクト: kuroiouji/c.s.i
        public override object MappingData(ISQLDbReader reader, Type otype)
        {
            object data = Activator.CreateInstance(otype);

            Type type = data.GetType();

            for (int colIdx = 0; colIdx < reader.TotalColumns; colIdx++)
            {
                string colName = reader.GetName(colIdx);
                System.Reflection.PropertyInfo prop = type.GetProperty(colName);
                if (prop != null)
                {
                    if (prop.CanWrite != true)
                    {
                        continue;
                    }

                    object val = reader.Value(colIdx, prop.PropertyType);
                    if (val == null)
                    {
                        continue;
                    }

                    prop.SetValue(data, val, null);
                }
            }

            return(data);
        }
コード例 #2
0
ファイル: SQLSvrDb.cs プロジェクト: kuroiouji/c.s.i
        private System.Collections.IList ToList(ISQLDbReader reader, Type type)
        {
            System.Collections.IList result =
                (System.Collections.IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(type));
            while (reader.Read())
            {
                result.Add(MappingData(reader, type));
            }

            return(result);
        }
コード例 #3
0
 public abstract object MappingData(ISQLDbReader reader, Type otype);
コード例 #4
0
ファイル: SQLSvrDb.cs プロジェクト: kuroiouji/c.s.i
 public override T MappingData <T>(ISQLDbReader reader)
 {
     return((T)MappingData(reader, typeof(T)));
 }
コード例 #5
0
 public abstract T MappingData <T>(ISQLDbReader reader) where T : class;