예제 #1
0
        public static DapperQueryHandle <T> AddCondition <T>(this DapperQueryHandle <T> queryHandle, Expression <Func <T, bool> > condition, string wheresql) where T : IQueryDto
        {
            if (condition.Compile()(queryHandle.ConditionObject))
            {
                var type       = queryHandle.ConditionObject.GetType();
                var properName = type.GetProperties().Where(a => wheresql.Contains(a.Name)).Select(a => a.Name).SingleOrDefault();
                if (string.IsNullOrEmpty(properName))
                {
                    throw new Exception("无效的条件参数!");
                }

                queryHandle.AddWHere(properName, wheresql);
            }

            return(queryHandle);
        }
예제 #2
0
 /// <summary>
 /// 创建参数DynamicParameters
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="queryHandle"></param>
 /// <returns></returns>
 public static (string sql, DynamicParameters parameter) Builder <T>(this DapperQueryHandle <T> queryHandle) where T : IQueryDto