本文整理汇总了C#中Sql.From方法的典型用法代码示例。如果您正苦于以下问题:C# Sql.From方法的具体用法?C# Sql.From怎么用?C# Sql.From使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql.From方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Build_ParentId_Query_For_IContent
public void Can_Build_ParentId_Query_For_IContent()
{
// Arrange
var sql = new Sql();
sql.Select("*");
sql.From("umbracoNode");
var query = Query<IContent>.Builder.Where(x => x.ParentId == -1);
// Act
var translator = new SqlTranslator<IContent>(sql, query);
var result = translator.Translate();
var strResult = result.SQL;
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE ([umbracoNode].[parentID] = -1)";
// Assert
Assert.That(strResult, Is.Not.Empty);
Assert.That(strResult, Is.EqualTo(expectedResult));
Console.WriteLine(strResult);
}
示例2: Can_Build_ContentTypeAlias_Query_For_IContentType
public void Can_Build_ContentTypeAlias_Query_For_IContentType()
{
// Arrange
var sql = new Sql();
sql.Select("*");
sql.From("umbracoNode");
var query = Query<IContentType>.Builder.Where(x => x.Alias == "umbTextpage");
// Act
var translator = new SqlTranslator<IContentType>(sql, query);
var result = translator.Translate();
var strResult = result.SQL;
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE ([cmsContentType].[alias] = 'umbTextpage')";
// Assert
Assert.That(strResult, Is.Not.Empty);
Assert.That(strResult, Is.EqualTo(expectedResult));
Console.WriteLine(strResult);
}
示例3: Can_Verify_Property_Collection_Query
public void Can_Verify_Property_Collection_Query()
{
var versionId = new Guid("2b543516-a944-4ee6-88c6-8813da7aaa07");
var id = 1050;
var expected = new Sql();
expected.Select("*");
expected.From("[cmsPropertyData]");
expected.InnerJoin("[cmsPropertyType]").On("[cmsPropertyData].[propertytypeid] = [cmsPropertyType].[id]");
expected.Where("[cmsPropertyData].[contentNodeId] = 1050");
expected.Where("[cmsPropertyData].[versionId] = '2b543516-a944-4ee6-88c6-8813da7aaa07'");
var sql = new Sql();
sql.Select("*")
.From<PropertyDataDto>()
.InnerJoin<PropertyTypeDto>()
.On<PropertyDataDto, PropertyTypeDto>(left => left.PropertyTypeId, right => right.Id)
.Where<PropertyDataDto>(x => x.NodeId == id)
.Where<PropertyDataDto>(x => x.VersionId == versionId);
Assert.That(sql.SQL, Is.EqualTo(expected.SQL));
Console.WriteLine(sql.SQL);
}