コード例 #1
0
ファイル: T3.cs プロジェクト: zyj0021/CRL5
        /// <summary>
        /// 在当前关联基础上再创建关联
        /// </summary>
        /// <typeparam name="T4"></typeparam>
        /// <param name="expression"></param>
        /// <param name="joinType"></param>
        /// <returns></returns>
        public LambdaQueryJoin <T, T2, T3, T4> Join <T4>(Expression <Func <T, T2, T3, T4, bool> > expression, JoinType joinType = JoinType.Inner)
        {
            var query2 = new LambdaQueryJoin <T, T2, T3, T4>(BaseQuery);

            BaseQuery.__Join <T4>(expression.Body, joinType);
            return(query2);
        }
コード例 #2
0
        /// <summary>
        /// 创建一个JOIN查询分支
        /// </summary>
        /// <typeparam name="T2">关联类型</typeparam>
        /// <returns></returns>
        public ILambdaQueryJoin <T, T2> Join <T2>(Expression <Func <T, T2, bool> > expression, JoinType joinType = JoinType.Inner)
        {
            var query2 = new LambdaQueryJoin <T, T2>(this);

            __Join <T2>(expression.Body, joinType);
            return(query2);
        }
コード例 #3
0
ファイル: T2.cs プロジェクト: zyj0021/CRL5
        /// <summary>
        /// 在当前关联基础上再创建关联
        /// </summary>
        /// <typeparam name="T3">再关联的类型</typeparam>
        /// <param name="expression">关联语法</param>
        /// <param name="joinType">关联类型</param>
        /// <returns></returns>
        public LambdaQueryJoin <T, T2, T3> Join <T3>(Expression <Func <T, T2, T3, bool> > expression, JoinType joinType = JoinType.Inner)
        {
            //like
            //query.Join<Code.Member>((a, b) => a.UserId == b.Id)
            //    .Select((a, b) => new { a.BarCode, b.Name })
            //    .Join<Code.Order>((a, b) => a.Id == b.Id);
            var query2 = new LambdaQueryJoin <T, T2, T3>(BaseQuery);

            BaseQuery.__Join <T3>(expression.Body, joinType);
            return(query2);
        }
コード例 #4
0
        /**
         * /// <summary>
         * /// Join,并返回筛选值
         * /// </summary>
         * /// <typeparam name="TJoin">关联类型</typeparam>
         * /// <param name="expression">关关表达式</param>
         * /// <param name="resultSelector">返回值,如果为空,则返回主表</param>
         * /// <param name="joinType">join类型,默认Inner</param>
         * /// <returns></returns>
         * public LambdaQuery<T> Join<TJoin>(
         *  Expression<Func<T, TJoin, bool>> expression,
         *  Expression<Func<T, TJoin, object>> resultSelector = null, JoinType joinType = JoinType.Inner) where TJoin : IModel, new()
         * {
         *  QueryFields.Clear();
         *  var innerType = typeof(TJoin);
         *  //TypeCache.SetDBAdapterCache(innerType, dBAdapter);
         *  string condition = FormatJoinExpression(expression);
         *  var resultFields = new List<Attribute.FieldAttribute>();
         *  if (resultSelector != null)
         *  {
         *      resultFields = GetSelectField(resultSelector.Body, innerType, false);
         *      QueryFields = resultFields;
         *  }
         *  AddInnerRelation(innerType, condition);
         *  return this;
         * }
         *
         * /// <summary>
         * /// 存入关联值到对象内部索引
         * /// </summary>
         * /// <typeparam name="TJoin">关联类型</typeparam>
         * /// <param name="expression">关联表达式</param>
         * /// <param name="resultSelector">选择的字段 如为null,则不返回</param>
         * /// <param name="joinType">join类型,默认Inner</param>
         * /// <returns></returns>
         * public LambdaQuery<T> AppendJoinValue<TJoin>(
         * Expression<Func<T, TJoin, bool>> expression,
         * Expression<Func<TJoin, object>> resultSelector = null, JoinType joinType = JoinType.Inner) where TJoin : IModel, new()
         * {
         *  var innerType = typeof(TJoin);
         *  if (QueryFields.Count == 0)
         *  {
         *      SelectAll();
         *  }
         *  string condition = FormatJoinExpression(expression);
         *  var resultFields = new List<Attribute.FieldAttribute>();
         *  if (resultSelector != null)
         *  {
         *      resultFields = GetSelectField(resultSelector.Body, innerType, true);
         *  }
         *  QueryFields.AddRange(resultFields);
         *  AddInnerRelation(innerType, condition);
         *  return this;
         * }
         **/
        #endregion

        /// <summary>
        /// 创建一个JOIN查询分支
        /// </summary>
        /// <typeparam name="TJoin">关联类型</typeparam>
        /// <returns></returns>
        public LambdaQueryJoin <T, TJoin> Join <TJoin>(Expression <Func <T, TJoin, bool> > expression, JoinType joinType = JoinType.Inner) where TJoin : IModel, new()
        {
            var query2    = new LambdaQueryJoin <T, TJoin>(this);
            var innerType = typeof(TJoin);

            __JoinTypes.Add(innerType, joinType);
            GetPrefix(innerType);
            string condition = FormatJoinExpression(expression.Body);

            AddInnerRelation(innerType, condition);
            return(query2);
        }
コード例 #5
0
ファイル: LambdaQueryJoin.cs プロジェクト: zhangyunyong/CRL3
        /// <summary>
        /// 在当前关联基础上再创建关联
        /// </summary>
        /// <typeparam name="TJoin2">再关联的类型</typeparam>
        /// <param name="expression">关联语法</param>
        /// <param name="joinType">关联类型</param>
        /// <returns></returns>
        public LambdaQueryJoin <TJoin, TJoin2> Join <TJoin2>(Expression <Func <TJoin, TJoin2, bool> > expression, JoinType joinType = JoinType.Inner) where TJoin2 : IModel, new()
        {
            //like
            //query.Join<Code.Member>((a, b) => a.UserId == b.Id)
            //    .Select((a, b) => new { a.BarCode, b.Name })
            //    .Join<Code.Order>((a, b) => a.Id == b.Id);
            var query2    = new LambdaQueryJoin <TJoin, TJoin2>(BaseQuery);
            var innerType = typeof(TJoin2);

            //BaseQuery.__JoinTypes.Add(new TypeQuery(innerType), joinType);
            BaseQuery.GetPrefix(innerType);
            string condition = BaseQuery.FormatJoinExpression(expression.Body);

            BaseQuery.AddInnerRelation(new TypeQuery(innerType), joinType, condition);
            return(query2);
        }