using System; using System.Linq.Expressions; using Umbraco.Core.Persistence.Querying; namespace Umbraco.Core.Persistence { /// /// Provides extension methods to . /// public static class SqlContextExtensions { /// /// Visit an expression. /// /// The type of the DTO. /// An . /// An expression to visit. /// An optional table alias. /// A SQL statement, and arguments, corresponding to the expression. public static (string Sql, object[] Args) Visit(this ISqlContext sqlContext, Expression> expression, string alias = null) { var expresionist = new PocoToSqlExpressionVisitor(sqlContext, alias); var visited = expresionist.Visit(expression); return (visited, expresionist.GetSqlParameters()); } /// /// Visit an expression. /// /// The type of the DTO. /// The type returned by the expression. /// An . /// An expression to visit. /// An optional table alias. /// A SQL statement, and arguments, corresponding to the expression. public static (string Sql, object[] Args) Visit(this ISqlContext sqlContext, Expression> expression, string alias = null) { var expresionist = new PocoToSqlExpressionVisitor(sqlContext, alias); var visited = expresionist.Visit(expression); return (visited, expresionist.GetSqlParameters()); } /// /// Visit an expression. /// /// The type of the first DTO. /// The type of the second DTO. /// An . /// An expression to visit. /// An optional table alias for the first DTO. /// An optional table alias for the second DTO. /// A SQL statement, and arguments, corresponding to the expression. public static (string Sql, object[] Args) Visit(this ISqlContext sqlContext, Expression> expression, string alias1 = null, string alias2 = null) { var expresionist = new PocoToSqlExpressionVisitor(sqlContext, alias1, alias2); var visited = expresionist.Visit(expression); return (visited, expresionist.GetSqlParameters()); } /// /// Visit an expression. /// /// The type of the first DTO. /// The type of the second DTO. /// The type returned by the expression. /// An . /// An expression to visit. /// An optional table alias for the first DTO. /// An optional table alias for the second DTO. /// A SQL statement, and arguments, corresponding to the expression. public static (string Sql, object[] Args) Visit(this ISqlContext sqlContext, Expression> expression, string alias1 = null, string alias2 = null) { var expresionist = new PocoToSqlExpressionVisitor(sqlContext, alias1, alias2); var visited = expresionist.Visit(expression); return (visited, expresionist.GetSqlParameters()); } } }