views:

468

answers:

2

nHibernate is giving the error : Custom type does not implement UserCollectionType: myApp.Domain.OrderLineCollection.

BindingList implements IList, so why is nHibernate trying to use UserCollectionType instead of IList?

public class OrderHeader
{
    public virtual int OrderHeaderId { get; set; }
    public virtual string OrderNumber { get; set; }
    public virtual OrderLineCollection Line { get; set; }
}

public class OrderLineCollection : BindingList<OrderHeader> { }

public class OrderHeaderMap : ClassMap<OrderHeader>
{
    public OrderHeaderMap()
    {
        WithTable("Orders");
        Id(x => x.OrderHeaderId, "OrderId").GeneratedBy.Identity();
        Map(x => x.OrderNumber);
        HasMany(x => x.Line).WithKeyColumn("OrderHeaderId").AsList();
    }
}

<list name="Line">
  <key column="OrderHeaderId" /> 
  <index /> 
  <one-to-many class="myApp.Domain.OrderLine, myApp.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
</list>
+2  A: 

NHibernate has it's own custom typed list which implements IList underneath.
I'm afraid you won't be able to use yours without creating nHibernate UserType.

But i might be wrong and would be glad to hear why. :)

Arnis L.
A: 
sirrocco
I modified the orginal question to show the xml that was produced by Fluent. Fluent is setting it to a List, but for some reason it is still not working.
Jon Masters