What is the ingenious way to delete data in LINQ
What is the clever way to delete data in LINQ? For this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.
Many friends in the implementation of LINQ delete data operation is often to read the data first, and then further consider deleting, then there is no easy way? Let's take a look at this simple method.
Linq to SQL delete data, do I have to read it first before deleting it? The answer is: not necessarily. Here is how to delete a key. The code is relatively simple and will not be explained, as follows:
LINQ deletes data instances through primary keys:
var user = new User{ID = 10}; db.Users.Attach(user); db.Users.Delete(user); db.SubmitChnages();
Is it easy to operate? What we need to pay attention to when executing LINQ to delete data is the relevance of the data.
About LINQ delete data clever way is what the answer to the question is shared here, I hope the above content can have some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.