public bool Fill <T>(object obj, string table, Dictionary <string, object> attachedWhere) where T : class, new() { SqlExpressionArgs args = new SqlExpressionArgs(); args.Table = table; args.Type = SqlExpressionType.Select; if (attachedWhere == null) { args.GenerateWhere = true; } else { args.GenerateWhere = false; args.AttachedWhere = AttachedWhereItem.Parse(attachedWhere); } //不能用 default(T) ,会是null SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(obj, args); DataSet ds = ExcuteDataSetSqlExpression(sqlExpression); List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]); Debug.Assert(dataList.Count <= 1, "Fill 时取出的记录大于1条"); if (dataList.Count != 1) { return(false); } T dataObj = dataList[0]; ReflectionHelper.Inject(obj, dataObj); return(true); }
public List <T> Select <T>(Dictionary <string, object> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new() { return(Select <T>(AttachedWhereItem.Parse(attachedWhere), pagingArgs)); }
public List <T> Select <T>(Dictionary <string, object> attachedWhere) where T : class, new() { return(Select <T>(AttachedWhereItem.Parse(attachedWhere), null)); }