private static List <T> ToList <T>(OracleDataReader reader, TypeDescription description) where T : class, new() { Type type = typeof(T); Dictionary <string, DbMapInfo> dict = description.MemberDict; List <T> list = new List <T>(); string[] names = GetColumnNames(reader); while (reader.Read()) { T obj = Activator.CreateInstance(type) as T; for (int i = 0; i < names.Length; i++) { string name = names[i]; DbMapInfo info; if (dict.TryGetValue(name, out info)) { object val = reader.GetValue(i); if (val != null && DBNull.Value.Equals(val) == false && (info.AttrIgnore == null || info.AttrIgnore.SelectConvert)) { if (info.AttrColumn != null && info.AttrColumn.TimeStamp) { info.PropertyInfo.FastSetValue(obj, val.ConvertToTimeStamp(info.PropertyInfo.PropertyType)); } else { info.PropertyInfo.FastSetValue(obj, val.Convert(info.PropertyInfo.PropertyType)); } } } } list.Add(obj); } return(list); }
internal static List <T> ToList <T>(DataTable table, TypeDescription description) where T : class, new() { Type type = typeof(T); Dictionary <string, DbMapInfo> dict = description.MemberDict; List <T> list = new List <T>(); foreach (DataRow row in table.Rows) { T obj = Activator.CreateInstance(type) as T; for (int i = 0; i < table.Columns.Count; i++) { string name = table.Columns[i].ColumnName; DbMapInfo info; if (dict.TryGetValue(name, out info)) { object val = row[i]; if (val != null && DBNull.Value.Equals(val) == false && info.AttrIgnore == null) { if (info.AttrColumn != null && info.AttrColumn.TimeStamp) { info.PropertyInfo.FastSetValue(obj, val.ConvertToTimeStamp(info.PropertyInfo.PropertyType)); } else { info.PropertyInfo.FastSetValue(obj, val.Convert(info.PropertyInfo.PropertyType)); } } } } list.Add(obj); } return(list); }
public static void SaveComplieResult(Type type, TypeDescription description) { s_typeInfoDict[type.FullName] = description; }