/// <summary> /// 返回单独实体 /// </summary> /// <returns></returns> public T ToSingleObject() { T retObj = default(T); using (IDataReader reader = this.ToDataReader()) { if (reader == null) { return(retObj); } EntityMapper <T, TableSchema> map = new EntityMapper <T, TableSchema>(includeTables); if (reader.Read()) { retObj = map.ConvertObject(reader); } reader.Close(); } return(retObj); }
/// <summary> /// 返回查询的结果集 /// </summary> /// <returns></returns> public List <T> ToList() { var list = new List <T>(); using (IDataReader reader = this.ToDataReader()) { if (reader == null) { return(list); } EntityMapper <T, TableSchema> map = new EntityMapper <T, TableSchema>(includeTables); while (reader.Read()) { list.Add(map.ConvertObject(reader)); } reader.Close(); } return(list); }