Polymorphic nhibernate query with projection -
using single table class hierarchy use projection flatten hierarchy present list of results user.
is there way using hql or criteria api without having issue multiple separate queries or unions?
classes
public class { public virtual long id { get; set; } } public class b : { public virtual datetime somedate { get; set; } public virtual otherentity other { get; set; } } public class c : { public virtual datetime? somedate { get; set; } public virtual string description { get; set; } } public class d : { public virtual string description { get; set; } } public class otherentity { public virtual string name { get; set; } }
sql tables:
create table items ( id bigint not null primary key, kind char(1) not null, somedate datetime null, description null ) create table otherentity ( id bigint not null primary key, name nvarchar(255) not null )
output projection:
public class itemreport { // a.id public virtual long id { get; set; } // b.somedate or c.somedate public virtual datetime? somedate { get; set; } // c.description or d.description public virtual string description { get; set; } // b.otherentity.name public virtual string othername { get; set; } }
Comments
Post a Comment