正在构建本地化应用程序。所有数据都需要以不同的语言提供。作为存储模型,我尝试使用Nhibernate,因为它比Entity Framework有更好的性能。我将一个根节点存储在数据库中以获取实体的唯一标识,然后使用每种语言的子节点(语言环境表)创建第二个表。在Nhibernate中映射本地化表格
我的数据库表如下所示:
Country
Int Id;
Country_Locale
Int Id;
Int CountryId;
String LangCode;
String Name;
City
Int Id;
Int CountryId;
City_Locale
Int Id;
Int CityId;
String LangCode;
String Name;
我的首选实体会是什么样子
Country
Int Id (from Coutry table)
String LangCode (from locale table)
String Name (from locale table)
IList<City> Cities (Referenced to City entity)
City
Int Id (From City table)
String LangCode (from locale table)
String Name (from locale table)
Country Country (Referenced to Country entity)
Int CountryId (From country table)
我意识到,我不能映射以上,但它是一种结构我宁愿。我怎么能做这个映射或者有其他建议。
** 编辑数据库表格布局使其更加清晰。
感谢您的回答。我已经在寻找类似的方法。它确实工作得很好。我喜欢这种渴望加载的东西,确实非常方便/在这种情况下需要(我还没有实现。) – Patrick 2013-04-14 16:46:30
@帕特里克 - 高兴地帮忙! – 2013-04-14 22:49:17