Iam trying to delete Addresses that associate to person before when user delete person I have problem as you see I try to get the person id to delete it from address before delete person error
Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.
Source Error:
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Person person = db.Persons.Find(id);
var address = (from u in db.Addresses
where u.PersonID.Equals(id)
select u.PersonID).SingleOrDefault();
db.Addresses.Remove(person);
db.Persons.Remove(person);
db.SaveChanges();
return RedirectToAction("Index");
}