0
創建標準,我有作爲問題在NHibernate的
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; }
}
我想申請左外的entitiy加入對這個表作爲
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
任何人都可以幫助我。
在此先感謝