答案 0 :(得分:1)
我相信您要模拟的将是一个对象,例如:
public class Team
{
public int Id { get; set; }
public string Name { get; set; }
public Supervisor Supervisor { get; set; }
public Location Location { get; set; }
}
实际上,使用Dapper最多可以实现七个对象,基本上您在SQL中会执行以下操作:
public IEnumerable<Team> GetTeams() => dbConnection.Query<Team, Supervisor, Location, Team>(query,
(team, supervisor, location, team) =>
{
team.Supervisor = supervisor,
team.Location = location,
return team;
});
您可以找到有关其多对象映射here的文档。我应该指出,除非另有说明,否则它会在ID上分开,并且对象在查询结果中出现的顺序也是如此。