예제 #1
0
        public List <T> Select <T>(List <AttachedWhereItem> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new()
        {
            SqlExpressionArgs args = new SqlExpressionArgs();

            args.Type          = SqlExpressionType.Select;
            args.GenerateWhere = false;
            args.AttachedWhere = attachedWhere;
            args.PagingArgs    = pagingArgs;

            //不能用 default(T) ,会是null
            SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(new T(), args);

            DataSet  ds       = ExcuteDataSetSqlExpression(sqlExpression);
            List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]);

            if (pagingArgs != null)
            {
                if (ds.Tables.Count > 1)
                {
                    pagingArgs.TotalRow = int.Parse(ds.Tables[1].Rows[0][0].ToString());
                }
                else
                {
                    pagingArgs.TotalRow = ds.Tables[0].Rows.Count;
                }
                pagingArgs.TotalPage = pagingArgs.TotalRow / pagingArgs.PageSize;
                if (pagingArgs.TotalRow % pagingArgs.PageSize > 0)
                {
                    pagingArgs.TotalPage++;
                }
            }

            return(dataList);
        }
예제 #2
0
 public List <T> Select <T>(SqlExpressionPagingArgs pagingArgs) where T : class, new()
 {
     return(Select <T>(new List <AttachedWhereItem>(), pagingArgs));
 }
예제 #3
0
 public List <T> Select <T>(Dictionary <string, object> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new()
 {
     return(Select <T>(AttachedWhereItem.Parse(attachedWhere), pagingArgs));
 }