How to configure Fluent NHibernate for many cars for many using Set instead of Bag?

http://www.codinginstinct.com/2010/03/nhibernate-tip-use-set-for-many-to-many.html

I want to do as the author suggested for the fluent nhibernate many-to-many, but instead of using it automatically instead of the HBM file, use the machine.

Here are my two entities

 public class User
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual Iesi.Collections.Generic.Set<City> Cities { get; set; }

}

 public class City{
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual Iesi.Collections.Generic.Set<User> Users { get; set; }

}

Tried using HashSet, IList and Set. But when I looked at the HBM files created when the automata output method was called:

 var autoMappings = new AutoPersistenceModel().AddEntityAssembly(entityAssembly).Where(x => x.Namespace.EndsWith("Domain"));

autoMappings.WriteMappingsTo((@"C:\TEMP");

He's still a bag type

<bag inverse="true" name="Users" table="MNUserCity" mutable="true">
      <key>
        <column name="CityId" />
      </key>
      <many-to-many class="MyApp.Entity.Domain.User, MyApp.Entity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
        <column name="UserId" />
      </many-to-many>
    </bag>

Are there any conventions / overrides that I can use in Fluent NHibernate to change the collection type for all ManyToMany in the application domain? I looked at the IHasManyToMany agreement, but did not understand.

Can anybody help? Thank.

, http://github.com/jagregory/fluent-nhibernate

+3
1

Users Cities Set ISet .

thread, "Automapper , , IList ISet".

+1

Source: https://habr.com/ru/post/1737731/


All Articles