I am getting error in adding the value to IEnumerable
type entity. Here is the restaurant
entity
public virtual ICollection<BusinessUser> BusinessUsers { get; set; }
Here is the businessUser
entity
public virtual ICollection<Restaurant> Restaurants { get; set; }
Here is the action method to add business user to the restaurant
public ActionResult Add(Restaurant restaurant)
{
if (ModelState.IsValid)
{
restaurant.DateAdded = DateTime.Now;
restaurant.BusinessUsers.Select(c => c.PersonID) = 2; // i want to assign the user with id 2 to this restaurant
db.Restaurants.Add(restaurant);
db.SaveChanges();
TempData["Success"] = "New Restaurant has been added successfully";
return RedirectToAction("Index");
}
return View(restaurant);
}
I see the following error in my editor:
Only assignment call increment decrement await and new object expressions can be used as a statement