Question

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. In my test case I only use one self-referencing lookup, although in practice there is two. The issue is explained in detail here.

Was it helpful?

Solution

Have you tried mapping to the view as if it was a table? I don't see any reason why this wouldn't work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top