0
所以我有一个实体称为VideoAsset映射到VideoCategory和组。两者都是多对多:nhibernate生成不正确的sql查询奇怪的别名
public class VideoAssetMap : IAutoMappingOverride<VideoAsset>
{
public void Override(AutoMapping<VideoAsset> mapping)
{
mapping.Map(x => x.Description)
.CustomSqlType("NTEXT");
mapping.HasManyToMany<Group>(x => x.Groups)
.Table("VideoAssetGroups")
.ParentKeyColumn("VideoAssetId")
.ChildKeyColumn("GroupId")
.AsSet();
mapping.HasManyToMany<VideoCategory>(x => x.Categories)
.Table("VideoCategoryRel")
.ParentKeyColumn("VideoCategoryId")
.ChildKeyColumn("VideoAssetId")
.AsSet();
}
}
当我尝试使用的SQLite运行在NUnit的下面的查询如下:
ICriteria query = this.Session.CreateCriteria<VideoAsset>("a")
.CreateAlias("a.Categories", "c")
.CreateAlias("a.Groups", " ag")
.Add(Restrictions.Eq("c.Id", category.Id))
.Add(Restrictions.Eq("a.Enabled", true));
我的SQL无法执行,因为它的分解:
inner join Groups alias_ ag2_ on groups4_.GroupId=alias_ ag2_.GroupId
我检查了我的数据库表,我不相信他们有什么问题。有任何想法吗?