Reputation: 2033
So I have An entity called VideoAsset that is mapped to a VideoCategory and Group. Both are many to many:
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();
}
}
When I try to run the following query in nunit with sqlite using the following:
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));
My sql can't execute because it's broken:
inner join Groups alias_ ag2_ on groups4_.GroupId=alias_ ag2_.GroupId
I checked my database tables and I don't believe there is anything wrong with them. Any Ideas?
Upvotes: 0
Views: 326
Reputation: 101
There is a space in your alias of the Groups property.
.CreateAlias("a.Groups", " ag")
Upvotes: 1