简体   繁体   English

FluentNHibernate映射到视图

[英]FluentNHibernate mapping to a view

I have a many to many relationship between entities and there is a table view acting as a lookup table defining the relationship. 我在实体之间有很多对很多的关系,并且有一个表视图充当定义该关系的查找表。

I'm curious how to map to a view as opposed to a table within a database. 我很好奇如何映射到视图而不是数据库中的表。

ie, Table mapping: 即,表映射:

public SomeMap()
{
    Id(...)//set Id and other mapped properties
    HasManyToMany(x => x.Items)
        .Table("SomeLookupTable")
        .ParentKeyColumn("ParentID")
        .ChildKeyColumn("ChildID")
        .LazyLoad()
        .Inverse()
        .Cascade.SaveUpdate();
}

UPDATE 更新

I just stumbled across something in the FluentNHibernate Google Group area regarding this. 我只是在FluentNHibernate Google Group区域中偶然发现了与此有关的东西。 In my test case I only use one self-referencing lookup, although in practice there is two. 在我的测试用例中,尽管实际上有两个,但我只使用一个自引用查找。 The issue is explained in detail here. 此问题在此处详细说明

Have you tried mapping to the view as if it was a table? 您是否尝试过像映射到表一样映射到视图? I don't see any reason why this wouldn't work. 我看不出有什么原因无法解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM