Exemple #1
0
        /// <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);
        }