Exemplo n.º 1
0
        /// <summary>
        /// 关联删除
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TJoin"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public override int Delete <TModel, TJoin>(Expression <Func <TModel, TJoin, bool> > expression)
        {
            var query = new RelationLambdaQuery <TModel>(dbContext);

            query.Join <TJoin>(expression);
            return(Delete(query));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 关联更新
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TJoin"></typeparam>
        /// <param name="expression"></param>
        /// <param name="updateValue"></param>
        /// <returns></returns>
        public override int Update <TModel, TJoin>(Expression <Func <TModel, TJoin, bool> > expression, ParameCollection updateValue)
        {
            var query = new RelationLambdaQuery <TModel>(dbContext);

            query.Join <TJoin>(expression);
            return(Update(query, updateValue));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 指定条件删除
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public override int Delete <TModel>(Expression <Func <TModel, bool> > expression)
        {
            LambdaQuery <TModel> query = new RelationLambdaQuery <TModel>(dbContext, false);

            query.Where(expression);
            string condition = query.FormatExpression(expression.Body).SqlOut;

            query.FillParames(this);
            return(Delete <TModel>(condition));
        }
Exemplo n.º 4
0
        internal override TType GetFunction <TType, TModel>(Expression <Func <TModel, bool> > expression, Expression <Func <TModel, TType> > selectField, FunctionType functionType, bool compileSp = false)
        {
            LambdaQuery <TModel> query = new RelationLambdaQuery <TModel>(dbContext, true);

            query.Select(selectField.Body);
            query.__FieldFunctionFormat = string.Format("{0}({1}) as Total", functionType, "{0}");
            query.Where(expression);
            var result = QueryScalar(query);

            if (result == null || result is DBNull)
            {
                return(default(TType));
            }
            return((TType)result);
        }