nhibernate / fluent-nhibernate

Fluent NHibernate!
BSD 3-Clause "New" or "Revised" License
1.66k stars 685 forks source link

Unable to automap a simple collection of IUserTypes #270

Open jasondentler opened 10 years ago

jasondentler commented 10 years ago

Using an IHasManyConvention convention as follows, I can almost generate the correct mapping. However, I can't remove the one-to-many element.

instance.AsSet();
var tableName = Inflector.Inflector.Pluralize(instance.EntityType.Name + instance.Member.Name);
instance.Table(tableName);
instance.Key.Column(instance.EntityType.Name + "Id");
instance.Element.Column("RoomId");
instance.Element.Type<RoomUserType>();

The one-to-many element is added by this code: https://github.com/jagregory/fluent-nhibernate/blob/master/src/FluentNHibernate/Automapping/Steps/CollectionStep.cs#L73

This is the closest I've been able to come to my desired mapping. I can't kill off the one-to-many with a convention.

<set name="Rooms" table="TestEntityRooms">
  <key>
    <column name="TestEntityId" />
  </key>
  <element type="JobService.Core.Enumerations.RoomUserType, JobService.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    <column name="RoomId" />
  </element>
  <one-to-many class="JobService.Core.Enumerations.Room, JobService.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</set>
chester89 commented 10 years ago

Can you please provide full example of your code? If that's not a public project, you can email me. By the way, which version of Fluent are you using?

chester89 commented 10 years ago

And it would be great if you provide a reason why you're trying to remove one2many. What behaviour are you after?