Hi Dharmendr,
I have done as per your provided example
but now facing other error
The entity or complex type cannot be constructed in a LINQ to Entities Query
please help also in this regards in below i have attached code and error.
[HttpPost]
public ActionResult Edit(int id)
{
OnlineShoppingEntities entities = new OnlineShoppingEntities();
var Category = entities.Tbl_Category.Where(x => x.CategoryId == id)
.Select(x => new Tbl_Category
{
CategoryId = x.CategoryId,
CategoryName = x.CategoryName//,
//Country = x.Country
}).FirstOrDefault();
return PartialView(Category);
}
[HttpPost]
public ActionResult EditP(Tbl_Category Category)
{
OnlineShoppingEntities entities = new OnlineShoppingEntities();
var CategoryUpdate = entities.Tbl_Category.Where(x => x.CategoryId == Category.CategoryId).FirstOrDefault();
CategoryUpdate.CategoryName = Category.CategoryName;
//CategoryUpdate.Country = customer.Country;
entities.SaveChanges();
return Json("Success");
}
Error Image Attached in below Link please check Error.