public DbVariableDeclaration( string name, DbDataType type, Expression expression) { _name = name; _type = type; _expression = expression; }
public DbNamedValueExpression(string name, DbDataType dbType, Expression value) : base(DbExpressionType.NamedValue, value.Type) { _name = name; _dbType = dbType; _value = value; }
protected override Expression VisitSelect(DbSelectExpression select) { select = (DbSelectExpression)base.VisitSelect(select); // look for redundant column declarations List <DbColumnDeclaration> cols = select.Columns.OrderBy(c => c.Name).ToList(); BitArray removed = new BitArray(select.Columns.Count); bool anyRemoved = false; for (int i = 0, n = cols.Count; i < n - 1; i++) { DbColumnDeclaration ci = cols[i]; DbColumnExpression cix = ci.Expression as DbColumnExpression; DbDataType qt = cix != null ? cix.DbType : null; DbColumnExpression cxi = new DbColumnExpression(ci.Expression.Type, qt, select.Alias, ci.Name); for (int j = i + 1; j < n; j++) { if (!removed.Get(j)) { DbColumnDeclaration cj = cols[j]; if (SameExpression(ci.Expression, cj.Expression)) { // any reference to 'j' should now just be a reference to 'i' DbColumnExpression cxj = new DbColumnExpression(cj.Expression.Type, qt, select.Alias, cj.Name); this.map.Add(cxj, cxi); removed.Set(j, true); anyRemoved = true; } } } } if (anyRemoved) { List <DbColumnDeclaration> newDecls = new List <DbColumnDeclaration>(); for (int i = 0, n = cols.Count; i < n; i++) { if (!removed.Get(i)) { newDecls.Add(cols[i]); } } select = select.SetColumns(newDecls); } return(select); }
public DbVariableExpression(string name, Type type, DbDataType dbType) : base((ExpressionType)DbExpressionType.Variable, type) { _name = name; _dbType = dbType; }
public QueryParameter(string name, Type type, DbDataType dbType) { this.name = name; this.type = type; this._dbType = dbType; }
public abstract string GetVariableDeclaration(DbDataType type, bool suppressSize);