ISqlWhereAndOr<TBuilder>.OrWhereRaw(string clause, params ISqlParameter[] parameters) Method
.NET Standard 2.x
Adds the OR
logical operator and a raw SQL to the WHERE clause.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TBuilder OrWhereRaw(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 OrWhereRaw method to add an OR condition (in raw SQL) to the WHERE clause.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlWhereAndOrExamples
{
public class OrWhereRawExample
{
private readonly SchoolContext _context;
public OrWhereRawExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlQueryBuilder();
// Defines a SQL statement and adds an OR WHERE condition (in raw SQL): Title = "Physics".
sqlbuilder.Select("*")
.From("Course")
.Where("CourseID", SqlBuilder.Parameter<int>("courid"))
.OrWhereRaw("Title = 'Physics'");
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
*
FROM [Course]
WHERE ([CourseID] = @courid
OR [Title] = 'Physics')
*/
}
}
}
Applies to
.NET Standard
2.x