ISqlJoinBuilder.FullJoin(string table, string alias, string schema) Method
.NET Standard 2.x
Uses the FULL OUTER JOIN
operator to join the original table source and the new table source to create a joined table. You need to specify a schema and an alias for the new table source.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlJoinOnBuilder FullJoin(string table, string alias, string schema);
Parameters
table
System.String
The name of the new table source.
alias
System.String
The alias of the new table source.
schema
System.String
The schema 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 demonstrates how to join a table with another using the FullJoin method.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlJoinBuilderExamples
{
public class FullJoinExample
{
private readonly SchoolContext _context;
public FullJoinExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example3()
{
var sqlQueryBuilder = new SqlQueryBuilder();
// Gets DepartmentID and Name from the "Department" table, and Title from the "Course" table.
// Sets to join "Department" table and "Course" table by: Department.DepartmentID = Course.DepartmentID.
// Specifies "CourseTable" as the alias for the table ("Course") to join, and "dbo" as the schema.
sqlQueryBuilder
.Select("Department.DepartmentID")
.Select("Department.Name")
.Select("CourseTable.Title")
.From("Department")
.FullJoin("Course", "CourseTable", "dbo")
.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]
FULL JOIN [dbo].[Course] AS [CourseTable]
ON [Department].[DepartmentID] = [CourseTable].[DepartmentID]
*/
}
}
}
Applies to
.NET Standard
2.x