In my application by clicking on the button, must add text this button in to LiST. Then I compare this list with the database. Table Category and Question have relations many to many. Here's the code:

 protected void ItemBound2(object sender, RepeaterItemEventArgs args)
        {
            categ = args.Item.DataItem as Category;

        }
 protected void Click_Button(object sender, EventArgs e)
        {
            var catlist = _repository.GetcategoryList();
         category.Add(catlist.FirstOrDefault(x=>x.CategoryId ==categ.CategoryId));

            _repository.GetQuestion(category);
        }

This is Repository:

  public List<Category> GetcategoryList()
        {

            IQueryable<Category> category = (from x in _context.Category
                select x);
            return category.ToList();
        }
   public List<Question> GetQuestion(List<Category> category )
        {
            var query = (from var in _context.Question
                                          where var.Category ==category
                                          select var);

            return query.ToList(); //here error!!!
        }

Related posts

Recent Viewed