4
如果數據庫中有一組嚴格包含字符串描述和ID的表,那麼通過NHibernate加載這些表的最佳方式是什麼?在查找表中使用NHibernate
所以假設我有一個三明治課,一個三明治有一個肉,一個奶酪和一個蔬菜,這三個東西在DB中是查找表。這似乎是最符合的NHibernate的理念,以具有
public class Meat { string name; int id; }
public class Cheese { string name; int id; }
public class Vegetable { string name; int id; }
public class Sandwich { Meat meat; Cheese cheese; Vegetable vegetable; }
但在數據庫中的幾十臺這樣的,似乎班迅速增殖。假設我這樣設置:
public class NameAndID { string name; int id; }
public class Sandwich { NameAndID meat; NameAndID cheese; NameAndID vegetable; }
這可行嗎?它將如何在Fluent NHibernate中實現?
我實際上在考慮保留單獨的表並讓它們全都映射到NameAndID。那可能嗎? –
...的種類...只需添加從NameAndID繼承的空類定義。你仍然需要映射每一個。 – dotjoe