FluentData.IntegrationTests/_Documentation/MappingTests.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using FluentData._Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace FluentData._Documentation
{
[TestClass]
public class MapperDocumentCode : BaseDocumentation
{
[TestMethod]
public void Query_auto_mapping_match()
{
List<Product> products = Context().Sql(@"select *
from Product")
.Query<Product>();
Assert.IsNotNull(products[0]);
}
[TestMethod]
public void Query_auto_mapping_custom_collection()
{
List<Product> products = Context().Sql(@"select *
from Product")
.Query<Product, ProductionCollection>();
Assert.IsNotNull(products[0]);
}
[TestMethod]
public void Query_auto_mapping_alias_manual()
{
List<Product> products = Context().Sql(@"select p.*,
c.CategoryId as Category_CategoryId,
c.Name as Category_Name
from Product p
inner join Category c on p.CategoryId = c.CategoryId")
.Query<Product>();
Assert.IsNotNull(products[0]);
Assert.IsNotNull(products[0].Category);
Assert.IsNotNull(products[0].Category.Name);
}
[TestMethod]
public void Query_auto_mapping_alias_expression()
{
List<Product> products = Context().Sql<Product>(@"select p.*,
c.CategoryId as {0},
c.Name as {1}
from Product p
inner join Category c on p.CategoryId = c.CategoryId",
x => x.Category.CategoryId,
x => x.Category.Name)
.Query<Product>();
Assert.IsNotNull(products[0]);
Assert.IsNotNull(products[0].Category);
Assert.IsNotNull(products[0].Category.Name);
}
后面还有 36 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
