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

code string

The 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

parameters contains 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

other InterpolatedSqlStatement

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

value string

The string from which to create an instance of InterpolatedSqlStatement.

Returns

InterpolatedSqlStatement

Exceptions

ArgumentNullException

value is 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

left InterpolatedSqlStatement

The first instance to compare.

right InterpolatedSqlStatement

The 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

value string

The string to convert to an instance of InterpolatedSqlStatement.

Returns

InterpolatedSqlStatement

Exceptions

ArgumentNullException

value is null.

operator !=(InterpolatedSqlStatement, InterpolatedSqlStatement)

Determines whether the two specified instances of InterpolatedSqlStatement are unequal.

public static bool operator !=(InterpolatedSqlStatement left, InterpolatedSqlStatement right)

Parameters

left InterpolatedSqlStatement

The first instance to compare.

right InterpolatedSqlStatement

The second instance to compare.

Returns

bool

true if the two the specified instances of InterpolatedSqlStatement are unequal; otherwise, false.