0
我想出这个:查询,如何让项目NUMER在特定的类
[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; }
}
工作。需要对p.Board.BoardID进行小小的修改,但不是什么大问题。 – 2011-05-10 12:42:06