1
votes

I need to Map the following property (Vms in Foo) using Fluent NHibernate:

public class Foo
{
    [DataMember]
    public IDictionary<VpgId, HashSet<VmId>> Vms 
    { get;  private set; }
}

public class VpgId
{
    [DataMember]
    public virtual Guid GroupGuid 
    { get; private set; }
}

public class VmId
{
    [DataMember]
    public virtual string VmName
    { get; private set; }

}

I tried to change HashSet to ISet and Add the following FNH configuration

.Override<Foo>(obj => obj.HasMany(x => x.Vms ).Cascade.AllDeleteOrphan())

But I get the following Exception:

threw exception. NHibernate.MappingException: NHibernate.MappingException: Association references unmapped class: System.Collections.Generic.ISet`1[[Common.VmId, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].

Q: How can I Map Collection which contains in a Collection?

1

1 Answers

1
votes

You can't map nested collections. You need to create a class that contains the inner collection (which needs to be a ISet). Then you can map it as a composite element.