流利Nhibernate编写的实体,指定外键 [英] Fluent Nhibernate composed entity, specify foreign key
本文介绍了流利Nhibernate编写的实体,指定外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class UserMap:ClassMap< PortalUser>
{
public UserMap()
{
WithTable(aspnet_Users);
Id(x => x.Id,UserId)
.GeneratedBy.Guid();
Map(x => x.Name,UserName);
Map(x => x.Login,LoweredUserName);
WithTable(LdapUsers,m => m.Map(x => x.FullName,FullName));
$ b code
$ b我的外键列在表 LdapUser是UserId,但是生成的select将会寻找一个PortalUserId。
有没有一种方法直接指定关系键? ...
WithTable( LdapUsers,m => {
m.Map(x => x.FullName,FullName);
m.WithKeyColumn(UserId);
});
I have a Fluent Nhibernate map like :
public class UserMap : ClassMap<PortalUser>
{
public UserMap()
{
WithTable("aspnet_Users");
Id(x => x.Id, "UserId")
.GeneratedBy.Guid();
Map(x => x.Name, "UserName");
Map(x => x.Login, "LoweredUserName");
WithTable("LdapUsers", m => m.Map(x => x.FullName, "FullName"));
}
}
My foreign key column in table "LdapUser" is UserId but the select that gets generated is going to look for a "PortalUserId".
Is there a way to specify the relation key direcly?
解决方案 Try this:
...
WithTable("LdapUsers", m => {
m.Map(x => x.FullName, "FullName");
m.WithKeyColumn("UserId");
});
这篇关于流利Nhibernate编写的实体,指定外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文