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); }
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); }
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; }
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; } }
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); }
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); }
public bool CompareMembers(SqlInfo info) { return Members.Count == info.Members.Count && !Members.Where((t,i) => !t.EqualsTo(info.Members[i])).Any(); }
public bool CompareLastMember(SqlInfo info) { return Members.Count > 0 && info.Members.Count > 0 && Members[Members.Count - 1].EqualsTo(info.Members[info.Members.Count - 1]); }
public bool CompareLastMember(SqlInfo info) { return (MemberChain.Length > 0 && info.MemberChain.Length > 0 && MemberChain[MemberChain.Length - 1].EqualsTo(info.MemberChain[info.MemberChain.Length - 1])); }
public bool CompareMembers(SqlInfo info) { return(MemberChain.Length == info.MemberChain.Length && !MemberChain.Where((t, i) => !t.EqualsTo(info.MemberChain[i])).Any()); }
public UnionMember(Member member, SqlInfo info) { Member = member; Infos.Add(info); }
public bool CompareLastMember(SqlInfo info) { return (Members.Count > 0 && info.Members.Count > 0 && Members[Members.Count - 1].EqualsTo(info.Members[info.Members.Count - 1])); }
public bool CompareMembers(SqlInfo info) { return(Members.Count == info.Members.Count && !Members.Where((t, i) => !t.EqualsTo(info.Members[i])).Any()); }