示例#1
0
            protected SqlInfo GetIndex(SqlInfo expr)
            {
                SqlInfo n;

                if (_indexes.TryGetValue(expr.Sql, out n))
                {
                    return(n);
                }

                if (expr.Sql is SqlField)
                {
                    var field = (SqlField)expr.Sql;
                    expr.Index = SelectQuery.Select.Add(field, field.Alias);
                }
                else
                {
                    expr.Index = SelectQuery.Select.Add(expr.Sql);
                }

                expr.Query = SelectQuery;

                _indexes.Add(expr.Sql, expr);

                return(expr);
            }
示例#2
0
		void SetInfo(SqlInfo info)
		{
			info.Query = SelectQuery;

			if (info.Sql == SelectQuery)
				info.Index = SelectQuery.Select.Columns.Count - 1;
			else
				info.Index = SelectQuery.Select.Add(info.Sql);
		}
示例#3
0
		SqlInfo CheckExpression(SqlInfo expression)
		{
			if (expression.Sql is SqlSearchCondition)
			{
				expression.Sql = Builder.Convert(
					new SqlFunction(typeof(bool), "CASE", expression.Sql, new SqlValue(true), new SqlValue(false)));
			}

			return expression;
		}
示例#4
0
		void SetInfo(SqlInfo info, MemberInfo? member)
		{
			info.Query = SelectQuery;

			if (info.Sql == SelectQuery)
				info.Index = SelectQuery.Select.Columns.Count - 1;
			else
			{
				info.Index = SelectQuery.Select.Add(info.Sql);
				if (member != null)
					SelectQuery.Select.Columns[info.Index].Alias = member.Name;
			}
		}
示例#5
0
            void CheckAndAddMember(IBuildContext sequence1, IBuildContext sequence2, SqlInfo info)
            {
                var member = new Member
                {
                    SequenceInfo     = info,
                    MemberExpression = Expression.PropertyOrField(_unionParameter, info.Member.Name)
                };

                if (sequence1.IsExpression(member.MemberExpression, 1, RequestFor.Object).Result)
                {
                    throw new LinqException("Types in {0} are constructed incompatibly.", _methodCall.Method.Name);
                }

                var idx = sequence2.ConvertToIndex(member.MemberExpression, 1, ConvertFlags.Field);

                if (idx[0].Index != member.SequenceInfo.Index)
                {
                    throw new LinqException("Types in {0} are constructed incompatibly.", _methodCall.Method.Name);
                }

                _members.Add(member.MemberExpression.Member, member);
            }
示例#6
0
        public virtual SqlInfo[] ConvertToIndex(Expression expression, int level, ConvertFlags flags)
        {
            var key = Tuple.Create(expression, level, flags);

            SqlInfo[] info;

            if (!_expressionIndex.TryGetValue(key, out info))
            {
                info = ConvertToIndexInternal(expression, level, flags);

                var newInfo = new SqlInfo[info.Length];

                for (var i = 0; i < info.Length; i++)
                {
                    var ni = info[i];

                    if (ni.Query != SqlQuery)
                    {
                        ni = new SqlInfo
                        {
                            Query  = SqlQuery,
                            Member = ni.Member,
                            Index  = SqlQuery.Select.Add(ni.Query.Select.Columns[ni.Index])
                        };
                    }

                    newInfo[i] = ni;
                }

                _expressionIndex.Add(key, newInfo);

                return(newInfo);
            }

            return(info);
        }
示例#7
0
 public bool CompareMembers(SqlInfo info)
 {
     return Members.Count == info.Members.Count && !Members.Where((t,i) => !t.EqualsTo(info.Members[i])).Any();
 }
示例#8
0
 public bool CompareLastMember(SqlInfo info)
 {
     return
         Members.Count > 0 && info.Members.Count > 0 &&
         Members[Members.Count - 1].EqualsTo(info.Members[info.Members.Count - 1]);
 }
示例#9
0
 public bool CompareLastMember(SqlInfo info)
 {
     return
         (MemberChain.Length > 0 && info.MemberChain.Length > 0 &&
          MemberChain[MemberChain.Length - 1].EqualsTo(info.MemberChain[info.MemberChain.Length - 1]));
 }
示例#10
0
 public bool CompareMembers(SqlInfo info)
 {
     return(MemberChain.Length == info.MemberChain.Length &&
            !MemberChain.Where((t, i) => !t.EqualsTo(info.MemberChain[i])).Any());
 }
示例#11
0
 public UnionMember(Member member, SqlInfo info)
 {
     Member = member;
     Infos.Add(info);
 }
示例#12
0
 public bool CompareLastMember(SqlInfo info)
 {
     return
         (Members.Count > 0 && info.Members.Count > 0 &&
          Members[Members.Count - 1].EqualsTo(info.Members[info.Members.Count - 1]));
 }
示例#13
0
 public bool CompareMembers(SqlInfo info)
 {
     return(Members.Count == info.Members.Count && !Members.Where((t, i) => !t.EqualsTo(info.Members[i])).Any());
 }