Reputation: 1414
I have some troubles with breeze and expanding deep properties. Here's the code:
public abstract class BaseEntity
{
public virtual Guid? Id { get; set; }
}
public partial class Request : BaseEntity
{
public virtual IList<ServiceBase> Services { get; set; }
public Request()
{
this.Services = new List<ServiceBase>();
}
}
public abstract class ServiceBase : BaseEntity
{
public virtual Guid? RequestId { get; set; }
public virtual Request Request { get; set; }
public virtual IList<Contact> Contacts { get; set; }
public ServiceBase()
{
Contacts = new List<Contact>();
}
}
public class ServiceTranslation : ServiceBase
{
public virtual string MyProp { get; set; }
}
public class ServiceModification : ServiceBase
{
public virtual string MyProp2 { get; set; }
}
public class BaseMapping<T> : ClassMapping<T> where T : BaseEntity
{
public BaseMapping()
{
this.Lazy(true);
//Schema("DEMO");
Id(x => x.Id, map => { map.Generator(Generators.GuidComb); });
}
}
public RequestMap()
{
this.Bag<ServiceBase>(x => x.Services, colmap =>
{
//colmap.Schema("demo");
colmap.Key(x => x.Column("RequestId"));
colmap.Inverse(false);
colmap.Cascade(Cascade.All);
}, map =>
{
map.OneToMany();
});
}
}
public ServicebaseMap()
{
this.Property(x => x.RequestId, map =>
{
map.Column("RequestId");
map.Insert(false);
map.Update(false);
map.NotNullable(true);
});
this.ManyToOne(x => x.Request, map =>
{
map.Column("RequestId");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
this.Bag<Contact>(x => x.Contacts, colmap =>
{
//colmap.Schema("demo");
colmap.Table("ServiceContact");
colmap.Key(x => { x.Column("ContactId"); });
colmap.Inverse(false);
colmap.Cascade(Cascade.All);
}, map =>
{
map.ManyToMany(x => { x.Column("ServiceId"); });
});
}
public class ServicetranslationMap : JoinedSubclassMapping<ServiceTranslation>
{
public ServicetranslationMap()
{
Property(x => x.MyProp);
}
}
public class ServiceModificationMap : JoinedSubclassMapping<ServiceModification>
{
public ServiceModificationMap()
{
Property(x => x.MyProp2);
}
}
A Request contains a collection of ServiceBase(Abstract) and those ServiceBase contains contacts.
If I try to expand like this:
http://localhost:61971/breeze/EAINHibernate/Requests?$expand=Services,Services.Contacts
Contacts are never expanded. Looking through the code, I found the ExpandMap
used by breeze in the InitializeWithCascade
methods of NHInitializer.cs
contains the type of the base class. But, when expanding, the type of the object in the collection is the concrete type, either ServiceTranslation or either ServiceModification.
What can we do in that kind of situation? Can we expect a fix?
Upvotes: 1
Views: 123
Reputation: 3209
Good catch! Yes, that's a bug and you can expect a fix.
Fixed now in GitHub. Fix will be included in the next release.
Upvotes: 3