/// <summary>
        /// 目前只支持单字段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="tKey"></typeparam>
        /// <param name="selectInfo"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public static SelectInfo <T> OrderByDescending <T, tKey>(this SelectInfo <T> selectInfo, Expression <Func <T, tKey> > predicate)
        {
            Expression       body         = predicate.Body;
            MemberExpression m            = (MemberExpression)body;
            PropertyInfo     propertyInfo = m.Member as PropertyInfo;
            string           orderByName  = propertyInfo.Name;
            string           orderByStr   = " " + orderByName + " DESC ";

            //处理先后关系
            selectInfo.orderByStr.Add(selectInfo.orderByStr.Count + 1, orderByStr);
            return(selectInfo);
        }
        public static CheckInfo Check <T>(this SelectInfo <T> selectInfo, ref List <ErrorList> erolt)
        {
            List <ErrorList> erolts = new List <ErrorList>();
            Dictionary <string, IConfigIO> retDic = new Dictionary <string, IConfigIO>();
            CheckInfo checkInfo = new CheckInfo();

            Type[] configIOList = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttribute <ConfigIOAttr>() != null).ToArray();
            foreach (Type type in configIOList)
            {
                Activator.CreateInstance(type.MakeGenericType(typeof(T)), selectInfo, erolts, checkInfo);
            }
            erolt = erolts;
            //检查错误
            return(checkInfo);
        }
示例#3
0
        public Errorinfo Check03(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (string.IsNullOrEmpty(selectInfo.strWhere))
            {
                errorinfo.Warning  = "strWhere is null";
                checkInfo.strWhere = "";
            }
            else
            {
                checkInfo.strWhere = selectInfo.strWhere;
            }
            return(errorinfo);
        }
示例#4
0
        public Errorinfo Check05(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.recordNum == -1)
            {
                errorinfo.Warning   = "recordNum is null,default is changed to 10";
                checkInfo.recordNum = 10;
            }
            if (errorinfo.Calibration && string.IsNullOrEmpty(errorinfo.Warning))
            {
                checkInfo.recordNum = selectInfo.recordNum;
            }
            return(errorinfo);
        }
示例#5
0
        public Errorinfo Check02(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.tableType == -1)
            {
                errorinfo.Warning   = "tableType is null,default is changed to Table";
                checkInfo.tableType = TableType.Table;
            }
            if (errorinfo.Calibration && string.IsNullOrEmpty(errorinfo.Warning))
            {
                checkInfo.tableType = selectInfo.tableType;
            }
            return(errorinfo);
        }
示例#6
0
        public Errorinfo Check01(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.tableName == null)
            {
                errorinfo.Calibration = false;
                errorinfo.Error       = "tableName is not null";
            }
            if (errorinfo.Calibration)
            {
                checkInfo.tableName = selectInfo.tableName;
            }
            return(errorinfo);
        }
示例#7
0
        public Check(SelectInfo <T> selectInfo, List <ErrorList> erolt, CheckInfo checkInfo)
        {
            var methods = GetType().GetMethods().Where(t => t.GetCustomAttribute <ConfigMethodAttr>() != null);

            foreach (MethodInfo method in methods)
            {
                ErrorList errorList  = new ErrorList();
                string    configName = method.GetCustomAttribute <ConfigMethodAttr>().Name.ToUpper();
                Errorinfo errorinfo  = method.Invoke(this, new object[] { selectInfo, checkInfo }) as Errorinfo;
                errorList.Name      = configName;
                errorList.Errorinfo = errorinfo;
                if (!errorinfo.Calibration || !string.IsNullOrEmpty(errorinfo.Warning))
                {
                    erolt.Add(errorList);
                }
            }
        }
示例#8
0
        public Errorinfo Check06(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo  = new Errorinfo();
            string    orderByStr = string.Empty;

            if (selectInfo.orderByStr.ToList().Count == 0)
            {
                errorinfo.Warning    = "orderByStr is null,default is changed to order by 1";
                checkInfo.orderByStr = "order by 1";
            }
            else
            {
                foreach (var item in selectInfo.orderByStr.ToList())
                {
                    orderByStr += "," + item.Value;
                }
                checkInfo.orderByStr = orderByStr;
            }
            return(errorinfo);
        }
 /// <summary>
 /// 分页
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="selectInfo"></param>
 /// <param name="pageNum"></param>
 /// <param name="recordNum"></param>
 /// <returns></returns>
 public static SelectInfo <T> SetPaging <T>(this SelectInfo <T> selectInfo, int pageNum, int recordNum = 0)
 {
     selectInfo.pageNum   = pageNum;
     selectInfo.recordNum = recordNum;
     return(selectInfo);
 }
示例#10
0
 /// <summary>
 /// 设置查询类型:TableType.Table/View
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="selectInfo"></param>
 /// <param name="tableType"></param>
 /// <returns></returns>
 public static SelectInfo <T> SetType <T>(this SelectInfo <T> selectInfo, int tableType)
 {
     selectInfo.tableType = tableType;
     return(selectInfo);
 }
示例#11
0
 /// <summary>
 /// Where语句:EF,DataBaseType.SqlServer, DataDeleteFlag.IsDelete
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="selectInfo"></param>
 /// <param name="predicate">Lambda</param>
 /// <param name="databaseType">数据库类型</param>
 /// <param name="IsDeleteFlag">是否开启删除标识</param>
 /// <returns></returns>
 public static SelectInfo <T> SetWhere <T>(this SelectInfo <T> selectInfo, Expression <Func <T, bool> > predicate, string databaseType, int IsDeleteFlag)
 {
     selectInfo.strWhere = SqlSugor.GetWhereStr <T>(predicate, DataBaseType.SqlServer, IsDeleteFlag == 1);
     return(selectInfo);
 }
示例#12
0
        public static GetByIdModel GetById <T>(this SelectInfo <T> selectInfo, string id)
        {
            GetByIdModel GetByIdModel = new GetByIdModel();

            return(GetByIdModel);
        }
示例#13
0
 /// <summary>
 /// 是否转换成json返回
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="selectInfo"></param>
 /// <param name="jsonFlag"></param>
 /// <returns></returns>
 public static SelectInfo <T> ToJson <T>(this SelectInfo <T> selectInfo, bool jsonFlag)
 {
     selectInfo.jsonFlag = jsonFlag;
     return(selectInfo);
 }
示例#14
0
        public Errorinfo Check07(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            return(errorinfo);
        }