nhibernate删除带有引用的批处理

nhibernate删除带有引用的批处理,nhibernate,hql,Nhibernate,Hql,termInfo类 public class TermInfo { public TermInfo() { this.Breviary = string.Empty; this.CreateBy = string.Empty; this.CreateDate = DateTime.Now; this.Group = 0; this.Name = string.Empty; } pub

termInfo类

public class TermInfo
{
    public TermInfo()
    {
        this.Breviary = string.Empty;
        this.CreateBy = string.Empty;
        this.CreateDate = DateTime.Now;
        this.Group = 0;
        this.Name = string.Empty;
    }

    public override int GetHashCode()

    public virtual int TermId { get; set; }

    public virtual string Name { get; set; }

    public virtual string Breviary { get; set; }

    public virtual int Group { get; set; }

    public virtual string CreateBy { get; set; }

    public virtual DateTime CreateDate { get; set; }

    public virtual IList<Taxonomy> Taxonomies { get; set; }
}
映射

internal class TaxonomyMap :  ClassMap<Taxonomy>
{
    public TaxonomyMap()
    {
        Table("Smart_TermTaxonomy");
        Id(x=>x.TaxonomyId).GeneratedBy.Identity();
        Map(x => x.Description);
        Map(x => x.OrderId);
        Map(x => x.ParentId);
        Map(x => x.PostCount);
        Map(x => x.TermTaxonomy).Column("Taxonomy");


        References(x => x.Term, "TermId");

        DynamicUpdate();
        DynamicInsert();
    }
}

internal class TermInfoMap : ClassMap<TermInfo>
{
    public TermInfoMap()
    {
        Table("Smart_PostTerms");
        Id(x=>x.TermId).GeneratedBy.Identity();
        Map(x => x.Breviary);
        Map(x => x.CreateBy);
        Map(x => x.CreateDate);
        Map(x => x.Group).Column("[Group]");
        Map(x => x.Name).Column("[Name]");

        HasMany<Taxonomy>(x => x.Taxonomies).KeyColumn("TermId");
    }
}
我的问题是,如何按术语.Name删除分类法 我期望的sql是:

'从smart\u postTaxonomy中删除,其中termId=从中选择termId smart_PostTerms,其中[Name]=@Name'


那么,我应该为此编写hql查询字符串什么呢?

您是否尝试过在hql中执行类似的操作

session.CreateQuery(
    "delete from Taxonomy t where t.Term.id = " +
    "  (select ti.id from TermInfo ti where ti.Name = :name)")
    .SetParameter("name", termName)
    .ExecuteUpdate();

您是否尝试过在HQL中执行类似的操作

session.CreateQuery(
    "delete from Taxonomy t where t.Term.id = " +
    "  (select ti.id from TermInfo ti where ti.Name = :name)")
    .SetParameter("name", termName)
    .ExecuteUpdate();