public void Populate(IndexedSqlDataReader dr) { this.Name = dr.Get <String>("name"); this.CanBeNull = dr.Get <Boolean>("is_nullable"); this.MaxStringLength = dr.Get <Int32>("max_length"); this.IsAutoIdentity = dr.Get <Boolean>("is_identity"); this.IsPrimaryKey = dr.Get <Boolean>("is_primarykey"); }
public static T Statement <T>(String statement, dynamic parameters = null, String connectionName = null) { using (var cmd = Command(connectionName)) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = statement; if (parameters != null) { Utility.AddParametersToCommand(parameters, cmd); } var type = typeof(T); using (var dr = new IndexedSqlDataReader(cmd.ExecuteReader(CommandBehavior.CloseConnection))) { if (dr.Read()) { if (type.IsValueType || type.Equals(typeof(String)) || type.Equals(typeof(DateTime))) { return(dr.Get <T>(0)); } return(dr.ReadObject <T>(returnNullOnEmpty: true)); } else { return(default(T)); } } } }
public static void Populate(object instance, IndexedSqlDataReader dr) { var thisType = instance.GetType(); var members = ModelCache.GetColumnMemberLookup(thisType); foreach (var col in members.Values) { col.SetValue(instance, dr.Get(col)); } }
/// <summary> /// Implementation of Populate. /// </summary> /// <param name="dr"></param> public void Populate(IndexedSqlDataReader dr) { this.TableName = dr.Get <String>("name"); }