【发布时间】:2014-12-15 05:55:32
【问题描述】:
您好,我有一个名为 Notifications 的类,它是用户的子类。
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string UserName { get; set; }
public ICollection<UserNotification> UserNotifications { get; set; }
}
public class Notification
{
public int Id { get; set; }
public ICollection<UserNotification> UserNotifications { get; set; }
public string Title { get; set; }
public string Message { get; set; }
public bool IsRead { get; set; }
public DateTime CreatedDate { get; set; }
}
public class UserNotification
{
public User User { get; set; }
public Notification Notification { get; set; }
}
现在我想通过 ID 获取用户,它将为当前用户带来所有通知。
var user = NhSession.Get<User>(userId);
但我不想收到所有通知。我只想让用户收到未读通知,只想为用户获取top 5 (Latest) notifications。
我试图通过 joinQueryOver 来实现,但我无法做到。任何人都可以建议让这个工作。
【问题讨论】:
标签: c# nhibernate queryover