Я придумал это:
[NotMapped]
public int ThreadsInBoard
{
get
{
ForumContextContainer ctx = new ForumContextContainer();
int thr = (from p in ctx.BoardSet
from x in ctx.ThreadSet
where p.BoardID == x.Board.BoardID
select p).Count();
}
}
То, что я хочу сделать, - это количество потоков в конкретной плате.Этот запрос на самом деле возвращает количество всех возможных потоков в базе данных и назначает его.Ниже участвуют занятия
public partial class Board
{
public int BoardID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsVisibleToGuests { get; set; }
public bool IsLocked { get; set; }
public Forum Forum { get; set; }
public ICollection<Thread> Thread { get; set; }
}
public partial class Thread
{
public int ThreadID { get; set; }
public User User { get; set; }
public ICollection<Post> Post { get; set; }
public Board Board { get; set; }
public ICollection<Subscription> Subscription { get; set; }
public ICollection<Poll> Poll { get; set; }
}