DeleteOnSubmit does not exist?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

These are my namespaces. I was looking for System.Data.Linq; but it seems to be nowhere, and I think this is what has been ported to System.Linq, since I have access to most of the other things in Linq. I 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");
}

***I was supposed to be DeleteOnSubmit, but I have only DeleteDatabaseand DeleteObjectI tried the latter, but it does not work.

You also tried dbcontent.Medlemmer.*, but still were not present.

And it AcceptAllChanges()should have been .submitChanges(), but it wasn’t.

+3
source share
5 answers

As far as I know, it DeleteOnSubmitcan only be called from a table, not from a DataContext. It looks like you are trying to call DeleteOnSubmitout of context.

dbcontent.Medlemmer.DeleteOnSubmit(member);

Linq to Entities, dbContent.DeleteObject(member) . dbContent.SaveChanges() . (AcceptAllChanges() ).

+4

DeleteOnSubmit DataContext - ITable Table<TEntity>. :

dbcontent.Medlemmer.DeleteOnSubmit(member);

DataContext.SubmitChanges , ...

, , System.Data.Linq . System.Data.Linq.dll? , , , DBEntities.

+1

System.Data.Linq Picture

+1

:

   foreach (var member in dQry)
    {
        dbcontent.Medlemmer.DeleteOnSubmit(member);
    }
+1

, System.Data.Linq.

However, like adding a link to System.Data.Linq, also delete the following usingstatuses:

//using System.Linq;
//using System.Linq.Expressions;
+1
source

Source: https://habr.com/ru/post/1784589/


All Articles