0

I have these classes:

class A
{
    public virtual Guid Id { get;set; }
    public virtual B Data { get; set; }
}

class B
{
    public IList<byte[]> InnerData1 { get; set; } // (1)
    public IList<C> InnerData2 { get; set; } // (2)
}

class C
{
    public int Value1 { get; set; }
    public int? Value2 { get; set; }
}

and following mappings for class A:

Id(x => x.Id).GeneratedBy.Guid();
Component(x => x.Data,
    m => 
        {
            m.HasMany(x => x.InnerData1).Element("InnerData1").Not.LazyLoad(); // (1)
            m.HasMany(x => x.InnerData2).Element("InnerData2").Not.LazyLoad(); // (2)
        });

as setting (1) works ok and it automatically creates a table and references it properly, I have a problem with (2) which is throwing an exception:

Could not determine type for: (...), for columns: NHibernate.Mapping.Column(InnerData1)

Why it creates everything ok for IList<byte[]> and has problems with IList<C> ? Do I have to set a separate mapping for C ? Is there no other simplier way? I would prefer not to add any additional ID column to my model there in C.

Firo
  • 30,626
  • 4
  • 55
  • 94
bodziec
  • 574
  • 1
  • 6
  • 23

1 Answers1

0

you have to explicitly map C because it is a composite type (type with multiple values). It does not need to have an explicit id column

HasMany(x => x.InnerData2)
    .Component(x => 
    {
        x.Map(c => c.Value1, "Value1").Not.Nullable();
        x.Map(c => c.Value2, "Value2");
    })
    .Not.LazyLoad();
Firo
  • 30,626
  • 4
  • 55
  • 94