Struct InterpolatedSqlStatement
- Namespace
- RentADeveloper.DbConnectionPlus.SqlStatements
- Assembly
- RentADeveloper.DbConnectionPlus.dll
Represents an SQL statement constructed using interpolated string syntax.
public struct InterpolatedSqlStatement : IEquatable<InterpolatedSqlStatement>
- Implements
- Inherited Members
Remarks
This type enables passing values as parameters and sequences of values as temporary tables to SQL statements via expressions inside interpolated strings. Therefore, this type implements the C# interpolated string handler pattern (see https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/interpolated-string-handler).
Constructors
InterpolatedSqlStatement(string, params (string Name, object? Value)[])
Initializes a new instance of the InterpolatedSqlStatement class from the specified SQL code and parameters.
public InterpolatedSqlStatement(string code, params (string Name, object? Value)[] parameters)
Parameters
codestringThe code of the SQL statement.
parameters(string Name, object Value)[]The parameters of the SQL statement.
Remarks
If a parameter value is an Enum, it is serialized according to EnumSerializationMode.
Exceptions
- ArgumentNullException
- ArgumentException
parameterscontains a duplicate parameter.
Methods
Equals(InterpolatedSqlStatement)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(InterpolatedSqlStatement other)
Parameters
otherInterpolatedSqlStatementAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FromString(string)
Creates a new instance of InterpolatedSqlStatement from the specified string.
public static InterpolatedSqlStatement FromString(string value)
Parameters
valuestringThe string from which to create an instance of InterpolatedSqlStatement.
Returns
Exceptions
- ArgumentNullException
valueis null.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(InterpolatedSqlStatement, InterpolatedSqlStatement)
Determines whether the two specified instances of InterpolatedSqlStatement are equal.
public static bool operator ==(InterpolatedSqlStatement left, InterpolatedSqlStatement right)
Parameters
leftInterpolatedSqlStatementThe first instance to compare.
rightInterpolatedSqlStatementThe second instance to compare.
Returns
- bool
true if the two specified instances of InterpolatedSqlStatement are equal; otherwise, false.
implicit operator InterpolatedSqlStatement(string)
Implicitly converts a string to an instance of InterpolatedSqlStatement.
public static implicit operator InterpolatedSqlStatement(string value)
Parameters
valuestringThe string to convert to an instance of InterpolatedSqlStatement.
Returns
Exceptions
- ArgumentNullException
valueis null.
operator !=(InterpolatedSqlStatement, InterpolatedSqlStatement)
Determines whether the two specified instances of InterpolatedSqlStatement are unequal.
public static bool operator !=(InterpolatedSqlStatement left, InterpolatedSqlStatement right)
Parameters
leftInterpolatedSqlStatementThe first instance to compare.
rightInterpolatedSqlStatementThe second instance to compare.
Returns
- bool
true if the two the specified instances of InterpolatedSqlStatement are unequal; otherwise, false.