using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
That’s my namespaces. I was looking for System.Data.Linq; but it doesn’t seem to be anywhere, and I guess that is what have been moved to System.Linq, since I have access to most other things in Linq. I’ve found System.Data:Linq, but no difference.
Here is my method:
public void deleteStudienummer(int studienummer)
{
dbcontent = new DBEntities();
var dQry = from members in dbcontent.Medlemmer
where members.Studienummer == studienummer
select members;
foreach (var member in dQry)
{
dbcontent.***
}
dbcontent.AcceptAllChanges();
Console.WriteLine("delete member should have occured");
}
The *** was supposed to be DeleteOnSubmit, but I only have DeleteDatabase and DeleteObject, I tried the latter but it doesn’t work.
Have also tried dbcontent.Medlemmer.* but still not present.
And AcceptAllChanges() was supposed to be .submitChanges() but that wasn’t present either.
As far as I know
DeleteOnSubmitcan only be called from a ‘Table’ not from a DataContext. Looks like you’re trying to callDeleteOnSubmitfrom the context.Should be
dbcontent.Medlemmer.DeleteOnSubmit(member);When using Linq to Entities as in this case
dbContent.DeleteObject(member)can be used to mark for deletion. After thatdbContent.SaveChanges()needs to be called to apply the changes. (AcceptAllChanges()won’t do the deletion).