Fluent NHibernate - HasMany().WithKeyColumnName

橙三吉。 提交于 2019-12-21 17:58:20

问题


I just got the latest version of Fluent from Google code and it seems some of the mapping has changed since I last used it.

Previously I could Map a relationship using the following when the id I was joining on had a different name in the second table

HasMany(x => x.Roles).WithTableName("tbl_Roles").WithKeyColumn("RoleId");

How is done in the latest release of Fluent?

Thanks


回答1:


HasMany(x => x.Roles)
  .WithTableName("tbl_Roles")
  .KeyColumns.Add("RoleId");

Multiple column support was added, so the method signature needed to be improved to make it clear what's happening.




回答2:


This works for me:

HasMany(x => x.Roles)
  .WithTableName("tbl_Roles")
  .KeyColumnNames.Add("RoleId");


来源:https://stackoverflow.com/questions/657056/fluent-nhibernate-hasmany-withkeycolumnname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!