diff --git a/QueryBuilder/Include.cs b/QueryBuilder/Include.cs index aefec7f4..f543920e 100644 --- a/QueryBuilder/Include.cs +++ b/QueryBuilder/Include.cs @@ -1,13 +1,39 @@ namespace SqlKata { + /// + /// Describes a related query that should be loaded together with the parent query result. + /// public class Include { + /// + /// Gets or sets the include name. + /// public string Name { get; set; } + + /// + /// Gets or sets the query used to load the related records. + /// public Query Query { get; set; } + + /// + /// Gets or sets the foreign key used to relate the included query to the parent query. + /// public string ForeignKey { get; set; } + + /// + /// Gets or sets the local key used to relate the parent query to the included query. + /// public string LocalKey { get; set; } + + /// + /// Gets or sets whether the include represents multiple related records. + /// public bool IsMany { get; set; } + /// + /// Creates a copy of the include definition. + /// + /// A cloned include definition. public Include Clone() { return new Include diff --git a/QueryBuilder/Join.cs b/QueryBuilder/Join.cs index ae0969a6..43ba7915 100644 --- a/QueryBuilder/Join.cs +++ b/QueryBuilder/Join.cs @@ -2,10 +2,16 @@ namespace SqlKata { + /// + /// Builds a SQL join clause and its join conditions. + /// public class Join : BaseQuery { protected string _type = "inner join"; + /// + /// Gets or sets the SQL join type. + /// public string Type { get @@ -18,10 +24,17 @@ public string Type } } + /// + /// Initializes a new inner join clause. + /// public Join() : base() { } + /// + /// Creates a copy of the join clause. + /// + /// A cloned join clause. public override Join Clone() { var clone = base.Clone(); @@ -29,6 +42,11 @@ public override Join Clone() return clone; } + /// + /// Sets the SQL join type. + /// + /// The join type, for example left join. + /// The current join instance. public Join AsType(string type) { Type = type; @@ -39,18 +57,61 @@ public Join AsType(string type) /// Alias for "from" operator. /// Since "from" does not sound well with join clauses /// - /// - /// + /// The table to join with. + /// The current join instance. public Join JoinWith(string table) => From(table); + + /// + /// Adds a subquery as the joined source. + /// + /// The subquery to join with. + /// The current join instance. public Join JoinWith(Query query) => From(query); + + /// + /// Adds a callback-created subquery as the joined source. + /// + /// A callback that configures the joined query. + /// The current join instance. public Join JoinWith(Func callback) => From(callback); + /// + /// Sets the join type to inner join. + /// + /// The current join instance. public Join AsInner() => AsType("inner join"); + + /// + /// Sets the join type to outer join. + /// + /// The current join instance. public Join AsOuter() => AsType("outer join"); + + /// + /// Sets the join type to left join. + /// + /// The current join instance. public Join AsLeft() => AsType("left join"); + + /// + /// Sets the join type to right join. + /// + /// The current join instance. public Join AsRight() => AsType("right join"); + + /// + /// Sets the join type to cross join. + /// + /// The current join instance. public Join AsCross() => AsType("cross join"); + /// + /// Adds a join condition comparing two columns. + /// + /// The first column name. + /// The second column name. + /// The comparison operator. + /// The current join instance. public Join On(string first, string second, string op = "=") { return AddComponent("where", new TwoColumnsCondition @@ -64,11 +125,22 @@ public Join On(string first, string second, string op = "=") } + /// + /// Adds an OR join condition comparing two columns. + /// + /// The first column name. + /// The second column name. + /// The comparison operator. + /// The current join instance. public Join OrOn(string first, string second, string op = "=") { return Or().On(first, second, op); } + /// + /// Creates a new join query instance. + /// + /// A new join instance. public override Join NewQuery() { return new Join(); diff --git a/QueryBuilder/SqlResult.cs b/QueryBuilder/SqlResult.cs index b84baf8a..4fb3adb4 100644 --- a/QueryBuilder/SqlResult.cs +++ b/QueryBuilder/SqlResult.cs @@ -6,19 +6,48 @@ namespace SqlKata { + /// + /// Represents the SQL text and bindings produced by compiling a . + /// public class SqlResult { private string ParameterPlaceholder { get; set; } private string EscapeCharacter { get; set; } + + /// + /// Initializes a new SQL result with the placeholder and escape character used by the compiler. + /// + /// The placeholder token used for parameter bindings. + /// The escape character used while replacing placeholders. public SqlResult(string parameterPlaceholder, string escapeCharacter) { ParameterPlaceholder = parameterPlaceholder; EscapeCharacter = escapeCharacter; } + + /// + /// Gets or sets the query that produced this result. + /// public Query Query { get; set; } + + /// + /// Gets or sets the raw SQL text before bindings are expanded. + /// public string RawSql { get; set; } = ""; + + /// + /// Gets or sets the ordered binding values for the compiled SQL. + /// public List Bindings { get; set; } = new List(); + + /// + /// Gets or sets the compiled SQL text. + /// public string Sql { get; set; } = ""; + + /// + /// Stores bindings by name for compilers that support named parameters. + /// public Dictionary NamedBindings = new Dictionary(); private static readonly Type[] NumberTypes = @@ -33,6 +62,10 @@ public SqlResult(string parameterPlaceholder, string escapeCharacter) typeof(ulong), }; + /// + /// Returns the raw SQL with binding values inlined for inspection and debugging. + /// + /// The SQL text with bindings converted to SQL literals. public override string ToString() { var deepParameters = Helper.Flatten(Bindings).ToList(); diff --git a/QueryBuilder/UnsafeLiteral.cs b/QueryBuilder/UnsafeLiteral.cs index 23d81e2d..591a6176 100644 --- a/QueryBuilder/UnsafeLiteral.cs +++ b/QueryBuilder/UnsafeLiteral.cs @@ -1,9 +1,20 @@ namespace SqlKata { + /// + /// Represents a raw SQL literal that should be inserted without parameter binding. + /// public class UnsafeLiteral { + /// + /// Gets or sets the literal SQL value. + /// public string Value { get; set; } + /// + /// Initializes a new unsafe SQL literal. + /// + /// The raw SQL value. + /// Whether single quotes should be escaped in the value. public UnsafeLiteral(string value, bool replaceQuotes = true) { if (value == null) diff --git a/QueryBuilder/Variable.cs b/QueryBuilder/Variable.cs index 63b936ea..1a61b706 100644 --- a/QueryBuilder/Variable.cs +++ b/QueryBuilder/Variable.cs @@ -1,9 +1,19 @@ namespace SqlKata { + /// + /// Represents a named variable placeholder that can be resolved by a query compiler. + /// public class Variable { + /// + /// Gets or sets the variable name. + /// public string Name { get; set; } + /// + /// Initializes a new variable placeholder. + /// + /// The variable name. public Variable(string name) { this.Name = name;