我有权作为
public class ClaimDetail
{
public virtual int Id { get; set; }
public virtual Claim Claim {get;set;}
public virtual string ServiceDateFrom { get; set; }
public virtual string DateCreated { get; set; }
public virtual ClaimDetail ParentClaimDetail { get; set; }
}
我想在此表上应用左外连接
SELECT cd.ClaimDetailId ,
cd.ParentClaimDetail_id ,
cds.ClaimDetailId ,
cds.ParentClaimDetail_id ,
cds.DateCreated,
cd.DateCreated
FROM ClaimDetail AS cd left JOIN ClaimDetail AS cds ON
cd.ClaimDetailId = cds.ParentClaimDetail_id
我在nhibernate中实现此查询为
ICriteria query = session.CreateCriteria(typeof(ClaimDetail), "cd")
.CreateAlias("ParentClaimDetail", "cds", NHibernate.SqlCommand.JoinType.LeftOuterJoin);
query.SetProjection
(
Projections.ProjectionList()
.Add(Projections.Property("cd.ParentClaimDetail.Id"), "sks")
.Add(Projections.Property("cd.Id"),"cdid")
.Add(Projections.Property("cds.DateCreated"), "dc1")
.Add(Projections.Property("cd.DateCreated"), "dc2")
.Add(Projections.Property("cds.ParentClaimDetail.Id"), "cds")
.Add(Projections.Property("cds.Id"),"cdsid")
);
但是这创建标准创建查询为
SELECT cd.ClaimDetailId ,
cd.ParentClaimDetail_id ,
cds.ClaimDetailId ,
cds.ParentClaimDetail_id ,
cds.DateCreated,
cd.DateCreated
FROM ClaimDetail AS cd left JOIN ClaimDetail AS cds ON
cd.ParentClaimDetail_id = cds.ClaimDetailId
任何人都可以帮助我。
提前致谢
答案 0 :(得分:0)
看起来您想要使用命名查询。命名查询在映射XML中,您可以将输入提供给它。此外,您可以选择自定义类来表示结果数据的实体。