public object Clone() { var newObject = new ModelCollection <T>(); foreach (var item in Items) { newObject.Add(item); } return(newObject); }
public static ModelCollection <T> ToModelCollection <T>(this IEnumerable <T> list) where T : IModel { ModelCollection <T> coll = new ModelCollection <T>(); foreach (var item in list) { coll.Add(item); } return(coll); }
private ModelCollection <T> QueryCollection <T>(ExecuteUnit unit) where T : new() { DataTable dt = this.DataHelper.ExecuteDataTable(unit.CommandText, unit.Session, unit.DbParams.ToArray()); ModelCollection <T> coll = new ModelCollection <T>(); Type elementType = coll.ElementType; foreach (DataRow row in dt.Rows) { T model = DataRowToT <T>(row); coll.Add(model); } return(coll); }