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; }
}
分类学类
public class Taxonomy
{
public Taxonomy()
{
this.TermTaxonomy = string.Empty;
this.Description = string.Empty;
this.ParentId = 0;
this.OrderId = 0;
this.PostCount = 0;
}
public virtual int TaxonomyId { get; set; }
public virtual string TermTaxonomy { get; set; }
public virtual string Description { get; set; }
public virtual int ParentId { get; set; }
public virtual int OrderId { get; set; }
public virtual int PostCount { get; set; }
public virtual TermInfo Term { 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");
}
}
我的问题是如何按术语删除分类法。命名我预期的 sql 将是:
'从 smart_postTaxonomy 中删除,其中 termId=(从 smart_PostTerms 中选择 termId,其中 [Name]=@Name)'
那么,我应该为此编写什么 hql 查询字符串?