Beispiel #1
0
        /// <summary>
        /// 选择TJoin关联值到对象内部索引
        /// 可调用多次,不要重复
        /// </summary>
        /// <param name="resultSelector"></param>
        /// <returns></returns>
        public LambdaQueryJoin <T, TJoin> SelectAppendValue(Expression <Func <TJoin, object> > resultSelector)
        {
            //var innerType = typeof(TJoin);
            if (BaseQuery.__QueryFields.Count == 0)
            {
                BaseQuery.SelectAll();
            }
            var resultFields = BaseQuery.GetSelectField(resultSelector.Body, true, typeof(T), typeof(TJoin));

            BaseQuery.__QueryFields.AddRange(resultFields);
            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// 选择TJoin关联值到对象内部索引
        /// 可调用多次,不要重复
        /// </summary>
        /// <param name="resultSelector"></param>
        /// <returns></returns>
        public LambdaQueryJoin <T, TJoin> SelectAppendValue <TResult>(Expression <Func <TJoin, TResult> > resultSelector)
        {
            //var innerType = typeof(TJoin);
            //if (BaseQuery.__QueryFields.Count == 0)
            //{
            //    BaseQuery.SelectAll();
            //}
            if (BaseQuery._CurrentSelectFieldCache == null)
            {
                BaseQuery.SelectAll();
            }
            var parameters   = resultSelector.Parameters.Select(b => b.Type).ToArray();
            var resultFields = BaseQuery.GetSelectField(true, resultSelector.Body, true, parameters).fields;

            //BaseQuery.__QueryFields.AddRange(resultFields);
            BaseQuery._CurrentAppendSelectField.AddRange(resultFields);
            return(this);
        }
        /// <summary>
        /// 选择TJoin关联值到对象内部索引
        /// 可调用多次,不要重复
        /// </summary>
        /// <param name="resultSelector"></param>
        /// <returns></returns>
        public ILambdaQuery <T> SelectAppendValue <TJoinResult2>(Expression <Func <TJoinResult, TJoinResult2> > resultSelector)
        {
            if (BaseQuery._CurrentSelectFieldCache == null)
            {
                BaseQuery.SelectAll(false);
            }
            var parameters  = resultSelector.Parameters.Select(b => b.Type).ToArray();
            var selectField = BaseQuery.GetSelectField(true, resultSelector.Body, true, parameters);
            var prefix1     = BaseQuery.GetPrefix(typeof(TJoinResult));
            var prefix2     = BaseQuery.GetPrefix(resultSelect.InnerType);

            //替换匿名前辍
            foreach (var item in selectField.mapping)
            {
                if (item.QueryFull.Contains(prefix1))
                {
                    item.QueryFull = item.QueryFull.Replace(prefix1, prefix2);
                }
            }

            BaseQuery.SetSelectFiled(selectField);
            return(BaseQuery as LambdaQuery <T>);
        }