C# N层网络游戏中的实体框架

C# N层网络游戏中的实体框架,c#,model-view-controller,entity-framework-6,n-tier-architecture,online-game,C#,Model View Controller,Entity Framework 6,N Tier Architecture,Online Game,我正在努力为一个在线游戏(教育项目,而不是商业项目)找到一个好的设计模式 假设我的数据库中有一个玩家表和一个地图表。 因此实体框架自动生成这些模型类: public partial class Map { public Map() { this.Players = new HashSet<Player>(); } public int MapID { get; set; } public string Name { get;

我正在努力为一个在线游戏(教育项目,而不是商业项目)找到一个好的设计模式

假设我的数据库中有一个玩家表和一个地图表。 因此实体框架自动生成这些模型类:

public partial class Map
{
    public Map()
    {
        this.Players = new HashSet<Player>();
    }

    public int MapID { get; set; }
    public string Name { get; set; }

    public virtual ICollection<Player> Players { get; set; }
}


public partial class Character
{
    public int CharacterID { get; set; }
    public string Name { get; set; }
    public int MapID { get; set; }

    public virtual Map Map { get; set; }
}
现在我想向PlayerController添加一个MapController属性(它将返回播放器所在地图的MapController)

我可以通过使用
this.\u player.Map
获取地图对象,但现在要找到地图控制器,我必须实现自己的地图控制器列表并搜索该列表。比如:

public class PlayerContoller
{
    private Player _player;
    private int _locationX;
    private int _locationY;

    public MapController MapController
    {
        get { globalListOfMapControllers.Search(this._player.Map); }
    }
}
这有点难看。我想有一个更好的方法来找到它,这将已经为我实现。(就像Player.Map一样) 此外,这是一个冗余搜索,因为
Player.Map
已经使用
Player.MapID
搜索地图对象

有人能想出一个更好的设计来设计这样一个系统吗

谢谢,, 布加莱

public class PlayerContoller
{
    private Player _player;
    private int _locationX;
    private int _locationY;

    public MapController MapController
    {
        get { globalListOfMapControllers.Search(this._player.Map); }
    }
}