我试图创建继承,这样我就可以拥有一些具有通用属性的超类,然后是更专业的类,这些类会被使用。
我想要他们在这里制作的每种类型的表或每个类的表http://www.codeproject.com/Articles/232034/Inheritance-mapping-strategies-in-Fluent-Nhibernat
所以我在这里有我的超类型游戏
public abstract class Game
{
public virtual int Id { get; set; }
public virtual List<UserGame> UserList { get; set; }
}
public class GameMap : ClassMap<Game>
{
public GameMap()
{
Id(x => x.Id, "GameId")
.GeneratedBy
.HiLo("100");
HasMany(x => x.UserList)
.Cascade.All();
}
}
然后我的专业课在这里 QMGameActive
public class QMGameActive : Game
{
public virtual DateTime LastUpdate { get; set; }
public virtual string SelectedBrick { get; set; }
public virtual int Score { get; set; }
public virtual string History { get; set; }
public virtual int StartingPlayerId { get; set; }
public QMGameActive()
{
LastUpdate = DateTime.Now;
History = "";
SelectedBrick = "";
}
}
public class QMGameActiveMap : SubclassMap<QMGameActive>
{
public QMGameActiveMap()
{
KeyColumn("GameId");
Map(x => x.LastUpdate);
Map(x => x.SelectedBrick);
Map(x => x.Score);
Map(x => x.History);
Map(x => x.StartingPlayerId);
}
}
但是当我从服务器获得图表时,我可以看到 Game 和 QMGameActive 之间没有连接
那么我错过了什么让它使用继承?