ISqlJoinBuilder.JoinRaw(string joinClause) Method
.NET Standard 2.x
Uses the INNER JOIN
operator to join the original table source directly with a raw SQL.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlJoinOnBuilder JoinRaw(string joinClause);
Parameters
joinClause
System.String
A string of raw SQL after the JOIN
keyword.
Returns
SnapObjects.Data.ISqlJoinOnBuilder
Returns an ISqlJoinOnBuilder
object that can be used to create the condition on which the join is based.
Examples
The following code example joins one table with another using the JoinRaw method.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlJoinBuilderExamples
{
public class JoinRawExample
{
private readonly SchoolContext _context;
public JoinRawExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example1()
{
var sqlQueryBuilder = new SqlQueryBuilder();
// Gets DepartmentID values and Name values from the "Department" table, and Title values from the "Course" table.
// Sets the condition to join the "Department" table and the "Course" table: Department.DepartmentID = Course.DepartmentID.
sqlQueryBuilder
.Select("Department.DepartmentID")
.Select("Department.Name")
.Select("Course.Title")
.From("Department")
.JoinRaw("Course On Department.DepartmentID = Course.DepartmentID");
// Converts to raw SQL for the database corresponding to the data context.
string sql = sqlQueryBuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code example produces the following output:
SELECT
[Department].[DepartmentID],
[Department].[Name],
[Course].[Title]
FROM [Department]
JOIN [Course]
ON [Department].[DepartmentID] = [Course].[DepartmentID]
*/
}
}
}
Applies to
.NET Standard
2.x