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); }
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); }
public abstract object MappingData(ISQLDbReader reader, Type otype);
public override T MappingData <T>(ISQLDbReader reader) { return((T)MappingData(reader, typeof(T))); }
public abstract T MappingData <T>(ISQLDbReader reader) where T : class;