开发者

ICriteria - fluent nhibernate not producing inner join

I am developing a small web application, using nhibnerate as my DAL. I have to classes that I wish to select from, using a simple ICriteria.

This is a sample of my code:

var criteria = CurrentSession.CreateCriteria(typeof(School))
    .CreateAlias("students", "s")
    .Add(Restrictions.Eq("s.Name", "Charley"));

From some reason this code generated a query with no inner join. I have only one table selected 开发者_运维百科from.

How can I solve this?

Thank you


Oenning's comment may be the answer but you should also specify the join type in CreateAlias:

var criteria = CurrentSession.CreateCriteria(typeof(School))
.CreateAlias("students", "s", JoinType.InnerJoin)
.Add(Restrictions.Eq("s.Name", "Charley"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜