0

我流利的映射是:

        HasOne(x => x.User).ForeignKey("fOM_User_Id").Cascade.None();

我的课是:

public class OrganizationMember
{
    public virtual int MemberId
    {
        get;
        set;
    }

    public virtual int OrganizationId
    {
        get;
        set;
    }

    public virtual int UserId
    {
        get;
        set;
    }

    public  virtual User User { get; set; }

    public virtual string Permissions
    {
        get;
        set;
    }

    public virtual System.DateTime DateAdded
    {
        get;
        set;
    }
}

我运行查询:

        var assignableusers = _session.Query<OrganizationMember>().Where(x => x.OrganizationId == CurrentProject.OwnerID)
            .Select(x => x.User.Login);

这产生了:

select user1_.fU_Login as col_0_0_ from tOrganization_Members organizati0_ left outer join tUsers user1_ on **organizati0_.fOM_Id**=user1_.fU_UserID where organizati0_.fOM_Organization_Id=7

但它应该是: select user1_.fU_Login as col_0_0_ from tOrganization_Members organizati0_ left outer join tUsers user1_ on **organizati0_.fOM_User_Id** = user1_.fU_UserID where organizati0_.fOM_Organization_Id = 7

如何在我的映射中解决这个问题?从organizati0_.fOM_Idorganizati0_.fOM_User_Id

4

1 回答 1

0

我不认为你们的关系是真正的一对一。

http://www.jagregory.com/writings/i-think-you-mean-a-many-to-one-sir/

您可能应该改用References(多对一)。

References(x => x.User).Cascade.None();
于 2012-10-10T01:18:12.153 回答