假设我有以下表格:
CREATE TABLE Game
(
GameId INT,
Name VARCHAR(50)
)
CREATE TABLE UserGameJoin
(
GameId INT,
UserId INT
)
CREATE TABLE User
(
UserId INT,
Username VARCHAR(50)
)
以及以下课程:
public class Game
{
public int GameId {get;set;}
public string Name {get;set;}
public List<User> Users {get;set;}
}
public class User
{
public int UserId {get;set;}
public string Username {get;set;}
}
我将如何从这个存储过程映射结果
CREATE PROC GetGamesAndUsers
AS
SELECT *
FROM Game
SELECT GameId, u.*
FROM Game g
INNER JOIN UserGameJoin j ON j.GameId = g.GameId
INNER JOIN User u ON u.UserId = j.UserId
到自动接口实现?
public interface IGameLibrary
{
List<Game> GetGamesAndUsers();
}
我通过添加来玩弄 Recordset 属性
[Recordset(1, typeof(User), Id = "GameId", IsChild = true)]
但是在调用 connection.As() 时会抛出 InvalidOperationException:“序列不包含匹配的元素。”