0

I have three table A , B , C;

//Table A
 public class Question
    {
        [Key]
        public int ID { get; set; }

        [Required]        
        public string Name { get; set; }

     }
//Table B
public class Answer
    {
        [Key]
        public int ID { get; set; }

        [Required]        
        public string Name { get; set; }

        [Required]        
        public int QusetionID { get; set; }

        [Required]        
        public int LocalID { get; set; }

     }

//Table C
public class Local
    {
        [Key]
        public int ID { get; set; }

        [Required]        
        public string Name { get; set; }

        [Required]        
        public int Localip { get; set; }
     }

What is the desired query Questions that are not answered by the Local How do you use except in the two matrices using ? With Entity Framework In Asp.net MVC I want to show a list of questions that are not answered?

string ip = Request.UserHostAddress;
var answerip = db.Answer.Where(l => l.Local.Localip == ip );
var quslist = db.Qustions.Except(answerip);
tereško
  • 58,060
  • 25
  • 98
  • 150
Sultan
  • 701
  • 1
  • 6
  • 19
  • What does table C have to do with your question? If it's not relevant, then don't include it in your question. – mason Mar 01 '16 at 17:29
  • The questions are not making much sense. Can you edit it to be more clear? Du you want all questions that does not have an answer or all questions what do not have an answer that, in turn, has a local? Also if these are the cases, what have you tried, are you expecting to use LINQ or? – Bjørn Sørensen Mar 01 '16 at 17:31
  • string ip = Request.UserHostAddress; var answerip = db.Answer.Where(l => l.Local.Localip == ip ); var quslist = db.Qustions.Except(answerip); – Sultan Mar 01 '16 at 17:40
  • I modify the question now Thank you for listening – Sultan Mar 01 '16 at 17:41

1 Answers1

0
List<int> tempIdList = answeripE.Select(q => q.ID).ToList();
var quslist = db.Qustion.Where(q => !tempIdList.Contains(q.ID));

Thanks for the creator of "daryal" Get All Except from SQL database using Entity Framework

Community
  • 1
  • 1
Sultan
  • 701
  • 1
  • 6
  • 19