ISqlJoinBuilder.RightJoin(string table, string alias) Method
.NET Standard 2.x
Creates a table by joining the original table source with a new table source using the RIGHT OUTER JOIN
operator. You need to specify an alias for the new table source.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlJoinOnBuilder RightJoin(string table, string alias);
Parameters
table
System.String
The name of the new table source.
alias
System.String
The alias of the new table source.
Returns
SnapObjects.Data.ISqlJoinOnBuilder
Returns an ISqlJoinOnBuilder
object which 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 RightJoin method.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlJoinBuilderExamples
{
public class RightJoinExample
{
private readonly SchoolContext _context;
public RightJoinExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example2()
{
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.
// Specifies "CourseTable" as the alias of the "Course" table.
sqlQueryBuilder
.Select("Department.DepartmentID")
.Select("Department.Name")
.Select("CourseTable.Title")
.From("Department")
.RightJoin("Course", "CourseTable")
.OnRaw("Department.DepartmentID = CourseTable.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],
[CourseTable].[Title]
FROM [Department]
Right JOIN [Course] AS [CourseTable]
ON [Department].[DepartmentID] = [CourseTable].[DepartmentID]
*/
}
}
}
Applies to
.NET Standard
2.x