I have a database in my WP8 application and I want to remove an item from the database when I press a button. All of the rows from the database is held in an observable collection called "person". How do I select the specific row I want and then remove it from the observable collection?
This is how I maybe thought it would be
public void DeletePerson(int personID)
{
IQueryable<PersonData> test = from PersonData personToDelete in personDB.PersonDataTable
where personToDelete.personID == personID
select personToDelete;
person.Remove(test);
personDB.PersonDataTable.DeleteOnSubmit(personToDelete);
personDB.SubmitChanges();
}
however the person.Remove()
only takes a PersonData
item (which is the table in question) and not an IQueryable
. So how do I get the PersonData
item I want?
You need to change like this
person.Remove(test.First());