ISqlWhereAndOr<TBuilder>.AndWhereRaw(string clause, params ISqlParameter[] parameters) Method
.NET Standard 2.x
Adds the AND
logical operator and a raw SQL to the WHERE clause.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TBuilder AndWhereRaw(string clause, params ISqlParameter[] parameters);
Parameters
clause
System.String
A string of raw SQL to be added to the WHERE clause.
parameters
SnapObjects.Data.ISqlParameter[]
(Optional) An array of ISqlParameter
objects which define the SQL parameters used in the raw SQL.
Returns
TBuilder
Returns the TBuilder
object which can be used to add more search conditions to the current WHERE clause.
Examples
The following code example demonstrates how to use the AndWhereRaw method to add an AND condition (in raw SQL) to the WHERE clause.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlWhereAndOrExamples
{
public class AndWhereRawExample
{
private readonly SchoolContext _context;
public AndWhereRawExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlQueryBuilder();
// Defines a SQL statement and adds an AND WHERE condition (in raw SQL): Title = "Physics".
sqlbuilder.Select("*")
.From("Course")
.Where("CourseID", SqlBuilder.Parameter<int>("courid"))
.AndWhereRaw("Title = 'Physics'");
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
*
FROM [Course]
WHERE ([CourseID] = @courid
AND [Title] = 'Physics')
*/
}
}
}
Applies to
.NET Standard
2.x