我遇到了意想不到的行为,我不清楚。当然我可以使用 distinct,但原因是什么?
我有实体(流畅的自动映射):
public class Ticket
{
public virtual int Id { get; set; }
public virtual string Title { get; set; }
public virtual IList<Activity> Activities { get; set; }
}
public class Activity
{
public virtual int Id { get; set; }
public virtual string Title { get; set; }
public virtual Ticket Ticket { get; set; }
}
测试数据(1 张票,5 个活动):
new Ticket { Id = 1, Activities = new List<Activity>
{
new Activity(), new Activity(), new Activity(), new Activity()
};
查询:_
var report = GetSessionFactory()
.OpenSession()
.QueryOver<Ticket>()
.JoinAlias(ticket => ticket.Activities, () => activity)
.List<Ticket>();
我有以下结果: