Have two tables : Rating and Books. Rating table has foreign key to the Books table.
These tables are mapped this way :
Books :
HasMany(x => x.RatingList).Cascade.All().Inverse();
and the Rating table :
References(x => x.Books).Column("BookId").Cascade.All();
Have this :
var bks = session.CreateCriteria("Books", "b");
using this restriction for selecting books
bks.Add(Restrictions.Eq("CategoryId",id));
here is the problem, how to join Rating table ??
bks.CreateAlias("b.Rating", "c");
bks.List();
return PartialView("/Views/Home/_Books.cshtml", bks);
The final result i need is to select all Books but also Rating for them. In the Rating table has many ratings for one book. Book rating should be given as average of ratings.
Some help ?