private SqlFragment HandleFunction(DbFunctionAggregate fa, SqlFragment arg) { Debug.Assert(fa.Arguments.Count == 1); if (fa.Function.NamespaceName != "Edm") { throw new NotSupportedException(); } FunctionFragment fragment = new FunctionFragment(); fragment.Name = fa.Function.Name; if (fa.Function.Name == "BigCount") { fragment.Name = "COUNT"; } else { fragment.Name = fa.Function.Name.ToUpperInvariant(); } fragment.Distinct = fa.Distinct; fragment.Argmument = arg; return(fragment); //return new CastExpression(aggregate, GetDbType(functionAggregate.ResultType.EdmType)); }
private SqlFragment GenericFunction(Dictionary <string, string> funcs, DbFunctionExpression e) { SqlFragment[] frags = new SqlFragment[e.Arguments.Count]; for (int i = 0; i < e.Arguments.Count; i++) { frags[i] = e.Arguments[i].Accept(callingGenerator); } string sql; switch (e.Function.Name) { case "Round": // Special handling for Round as it has more than one signature. sql = HandleFunctionRound(e); break; default: sql = String.Format(funcs[e.Function.Name], frags); break; } return(new LiteralFragment(sql)); }
public void AddGroupBy(SqlFragment f) { if (GroupBy == null) { GroupBy = new List <SqlFragment>(); } GroupBy.Add(f); }
public RelationalCommand GenerateSql(IDictionary <string, object> parameterValues) { SqlFragment fragment = null; DbExpression e = commandTree.Query; switch (commandTree.Query.ExpressionKind) { case DbExpressionKind.Project: fragment = e.Accept(this); Debug.Assert(fragment is SelectStatement); break; } return(fragment.ToString()); }
public override string GenerateSQL(DbCommandTree tree) { DbQueryCommandTree commandTree = tree as DbQueryCommandTree; SqlFragment fragment = null; DbExpression e = commandTree.Query; switch (commandTree.Query.ExpressionKind) { case DbExpressionKind.Project: fragment = e.Accept(this); Debug.Assert(fragment is SelectStatement); break; } return(fragment.ToString()); }
public override string GenerateSQL(DbCommandTree tree) { DbInsertCommandTree commandTree = tree as DbInsertCommandTree; InsertStatement statement = new InsertStatement(); DbExpressionBinding e = commandTree.Target; statement.Target = (InputFragment)e.Expression.Accept(this); foreach (DbSetClause setClause in commandTree.SetClauses) { statement.Sets.Add(setClause.Property.Accept(this)); } foreach (DbSetClause setClause in commandTree.SetClauses) { DbExpression value = setClause.Value; SqlFragment valueFragment = value.Accept(this); statement.Values.Add(valueFragment); if (values == null) { values = new Dictionary <EdmMember, SqlFragment>(); } if (value.ExpressionKind != DbExpressionKind.Null) { EdmMember property = ((DbPropertyExpression)setClause.Property).Property; values.Add(property, valueFragment); } } if (commandTree.Returning != null) { statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning); } return(statement.ToString()); }
public override string GenerateSQL(DbCommandTree tree) { DbUpdateCommandTree commandTree = tree as DbUpdateCommandTree; UpdateStatement statement = new UpdateStatement(); //scope.Push(commandTree.Target.VariableName); statement.Target = commandTree.Target.Expression.Accept(this); foreach (DbSetClause setClause in commandTree.SetClauses) { statement.Properties.Add(setClause.Property.Accept(this)); DbExpression value = setClause.Value; SqlFragment valueFragment = value.Accept(this); statement.Values.Add(valueFragment); if (values == null) { values = new Dictionary <EdmMember, SqlFragment>(); } if (value.ExpressionKind != DbExpressionKind.Null) { EdmMember property = ((DbPropertyExpression)setClause.Property).Property; values.Add(property, valueFragment); } } statement.Where = commandTree.Predicate.Accept(this); if (commandTree.Returning != null) { statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning); } return(statement.ToString()); }
public SortFragment(SqlFragment column, bool ascending) { Column = column; Ascending = ascending; }
public void Append(SqlFragment s) { Fragments.Add(s); }
public ExistsFragment(SqlFragment f) { Argument = f; }
public void AddGroupBy(SqlFragment f) { if (GroupBy == null) GroupBy = new List<SqlFragment>(); GroupBy.Add(f); }
private SqlFragment GenericFunction(Dictionary<string, string> funcs, DbFunctionExpression e) { SqlFragment[] frags = new SqlFragment[e.Arguments.Count]; for (int i = 0; i < e.Arguments.Count; i++) frags[i] = e.Arguments[i].Accept(callingGenerator); string sql; switch (e.Function.Name) { case "Round": // Special handling for Round as it has more than one signature. sql = HandleFunctionRound(e); break; default: sql = String.Format(funcs[e.Function.Name], frags); break; } return new LiteralFragment(sql); }
private SqlFragment HandleFunction(DbFunctionAggregate fa, SqlFragment arg) { Debug.Assert(fa.Arguments.Count == 1); if (fa.Function.NamespaceName != "Edm") throw new NotSupportedException(); FunctionFragment fragment = new FunctionFragment(); fragment.Name = fa.Function.Name; if (fa.Function.Name == "BigCount") fragment.Name = "COUNT"; else fragment.Name = fa.Function.Name.ToUpperInvariant(); fragment.Distinct = fa.Distinct; fragment.Argmument = arg; return fragment; //return new CastExpression(aggregate, GetDbType(functionAggregate.ResultType.EdmType)); }