mvc3将重复记录计为1

时间:2013-05-06 21:27:07

标签: asp.net-mvc-3 count null

我有一个用户可以发帖的网站..他们最多可以有 10个独立帖子。我有10个数据库字段,分别是post_1,post_2 ... post_10,如果post_#为空,那么它将为null我怎么能用实体循环post_1 - > post_10并计算有多少Nulls 如果没有帖子是Null我可以阻止另一个帖子发生。所有Post_#都是Nullable INT的

// here i check for the RegistrationID and the first 2 Post_#
// however this code is wrong as I want to loop post 1-10 and get the Null Count
 var getlistings = (from s in db.posters where getid.RegistrationID == s.RegistrationID && s.Post_1 == null && s.Post_2== null select s.RegistrationID).Count();

我知道如何解决这个问题吗?

0 个答案:

没有答案