Note that there are some explanatory texts on larger screens.

plurals
  1. POConfORM Nhibernate OneToManyKeyColumnApplier Problem
    primarykey
    data
    text
    <p>I am using ConfORM Nhibernate in one of my MVC project. And had problem with One to Many Mappings. </p> <pre><code> IEnumerable&lt;Type&gt; domainEntities = this.GetDomainEntities(); var relationalMapper = new ObjectRelationalMapper(); relationalMapper.TablePerConcreteClass(domainEntities); relationalMapper.Patterns.PoidStrategies.Add(new NativePoidPattern()); relationalMapper.Cascade&lt;Category, Product&gt;(Cascade.All); relationalMapper.ManyToMany&lt;Category, Product&gt;(); relationalMapper.Cascade&lt;Order, Product&gt;(Cascade.Persist); var mapper = new Mapper(relationalMapper); var englishInflector = new EnglishInflector(); mapper.PatternsAppliers.Merge(new ClassPluralizedTableApplier(englishInflector)); mapper.PatternsAppliers.Merge(new OneToManyKeyColumnApplier(relationalMapper)); ..... HbmMapping mapping = mapper.CompileMappingFor(domainEntities); </code></pre> <p>And classes Order and User: One User had many Orders.</p> <pre><code> public class Order : BaseEntity { public Order(User user) { if (user == null) { throw new ArgumentNullException("user"); } this.User = user; } protected Order() { } public virtual User User { get; protected set; } } </code></pre> <p>And Users:</p> <pre><code> public class User : BaseEntity { public User() { this.Orders = new HashedSet&lt;Order&gt;(); } public virtual string FirstName { get; set; } public virtual ISet&lt;Order&gt; Orders { get; protected set; } } </code></pre> <p>I expect relations like this: Orders.UserId -> User.Id in the DB. But when the Nhibernate had genereted DB we had this problem (See image):</p> <p><img src="https://i.stack.imgur.com/PK9I9.jpg" alt="table structure"></p> <p>UPS. Double reference User and UserId suddenly uppeared. And when we removed [user] Nhivernate can`t do inner join this tables. It sad that double time: Invalid column name 'User'. Invalid column name 'User'.</p> <p>I think there is some problems with setuping ConfORM. If I remove mapper.PatternsAppliers.Merge(new OneToManyKeyColumnApplier(relationalMapper)); ConfORM generete just [User] reference key.</p> <p>Anyone know what the problem is here? Thanks in Advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload