Fluent NHibernate - HasMany().WithKeyColumnName

2020-07-18 03: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

2条回答
迷人小祖宗
2楼-- · 2020-07-18 03:49
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.

查看更多
放我归山
3楼-- · 2020-07-18 04:11

This works for me:

HasMany(x => x.Roles)
  .WithTableName("tbl_Roles")
  .KeyColumnNames.Add("RoleId");
查看更多
登录 后发表回答