ISqlJoinBuilder.GetJoinType(string tableName) Method
.NET Standard 2.x
Gets the type of the JOIN operation for the specified table source.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
SqlJoinType? GetJoinType(string tableName);
Parameters
tableName
System.String
The name of the table source.
Returns
Returns the value of the SqlJoinType
enumerated type of the JOIN operation if a JOIN operation was specified; otherwise, returns null.
Examples
The following code example demonstrates how to use the GetJoinType method to get the JOIN type.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlJoinBuilderExamples
{
public class GetJoinTypeExample
{
private readonly SchoolContext _context;
public GetJoinTypeExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
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.
sqlQueryBuilder
.Select("Department.DepartmentID")
.Select("Department.Name")
.Select("Course.Title")
.From("Department")
.FullJoin("Course")
.OnRaw("Department.DepartmentID = Course.DepartmentID")
.ToSqlString(_context);
// Converts to raw SQL for the database corresponding to the data context.
string sql = sqlQueryBuilder.ToSqlString(_context);
Console.WriteLine(sql);
// Gets the JOIN type for joining the "Department" table and the "Course" table.
var sqlJoinType = sqlQueryBuilder.GetJoinType("Course");
Console.WriteLine("SqlJoinType:{0}", sqlJoinType);
/*This code example produces the following output:
SELECT
[Department].[DepartmentID],
[Department].[Name],
[Course].[Title]
FROM [Department]
FULL JOIN [Course]
ON [Department].[DepartmentID] = [Course].[DepartmentID]
SqlJoinType:Full
*/
}
}
}
Applies to
.NET Standard
2.x