0

このようなものをlinqで実装するにはどうすればよいですか。私のlinqコードでは、回答のユーザーIDが質問のユーザーIDと等しくない場合に最良の回答が得られます。これは、ユーザーが自分の投稿をベストアンサーとして選択することをフィルタリングすることを想定しています。ユーザーが自分の回答を最良の回答として選択した場合、少なくとも 3 回賛成票を投じる必要があります。

var AwardedAnswers = from u in context.userinfo
                     select new
                     {
                        u.user_userid,
                        u.user_username,
                        u.user_GravatarHash,
                        Answers = from ans in context.post
                                  let QuestionUserID = (from q in context.post
                                            where q.post_id == ans.post_parentid
                                            select new
                                            {
                                                    q.userinfo.user_userid
                                            }).FirstOrDefault()
                               where ans.userinfo.user_userid == u.user_userid 
                               && !object.Equals(ans.post_parentid, null) 
                               && ans.post_isselected == true 
                                    //this is where my trouble is
                                    //this filters answers made by the original poster
                                    //This should filter unless the Vote count is higher then 2
                               && (ans.userinfo.user_userid != QuestionUserID.user_userid)
                               select new
                               {
                                ans.post_id,
                                    ans.post_parentid
                               }

                      };
4

1 に答える 1

3

どうですか:

 && (ans.userinfo.user_userid != QuestionUserID.user_userid
     || ans.upvotes >= 3)

ただし、これは推測にすぎません。投票に関するデータベース構造がどのようなものかはわかりません。

于 2010-02-08T06:58:03.883 に答える