score:1
Accepted answer
int userid = ...
using (var dbcontext = new mydbcontext())
{
dbcontext.removeuser(userid);
}
score:1
var customobjectqueryable = _context.users.where(x => x.id == request.userid);
var entity = customobjectqueryable
.include(x => x.notificationscreated)
.include(x => x.uservisibility)
.first();
var entry = _context.entry(entity);
entry.collection(x => x => x.usersmeetings).load();
entry.collection(x => x.usersgroups).load();
entry.collection(x => x.roles).load();
entry.collection(x => x.refreshtokens).load();
entry.collection(x => x.groups).load();
entry.collection(x => x.notifications).load();
entry.collection(x => x.meetings).load();
entity.usersmeetings.clear();
entity.usersgroups.clear();
entity.roles.clear();
entity.refreshtokens.clear();
entity.group.clear();
entity.notifications.clear();
entity.meetings.clear();
_context.savechanges();
Source: stackoverflow.com
Related Query
- Delete all related rows to user using EF .NET CORE
- How to get a list of user dialogs from the database of all messages using Entity Framework Core
- How to check the user already offer the ride using LINQ in NET Core
- Entity Framework. Delete all rows in table
- Select all rows with distinct column value using LINQ
- How do I delete all child elements using linq to sql?
- Read all rows of a specific column using LINQ
- Delete all records from a database using LINQ to SQL
- how to delete multiple rows of data with linq to EF using DbContext
- How to delete multiple rows using LINQ in linq2db Templates based on two tables?
- Using LINQ to Entity without putting all rows in memory
- Match all rows on particular day using LINQ to SQL
- Using Linq to find all rows that match these conditions
- EF linq, delete all related OwnerId to Id
- Find All Rows in DataTable Where Column Value is NOT Unique Using Linq Query
- Dynamic Query based on all optional parameters using an OR condition in ef core
- load related enties without using include in Entity Framework Core
- Using Linq to find all records in table that have a specific value in a related table using method syntax
- Select all fields from collection with related items in another collection using LINQ
- Selecting all rows based on a distinct column in Entity Framework Core
- Problem reading rows from database using EF Core and conditional WHERE clauses
- Upgraded to .NET Core 3.1 and receiving an error in a LINQ query related to using .FirstOrDefault()
- How to implement pagination with group by using Entity Framework Core 3.0 without retrieving all rows?
- CRM 2013 Retrieve all teams for a given user using LINQ
- Net Core 3.1 Entity Framework: Get all records where a property is NOT included
- using LINQ to delete specific rows from DataTable
- How can I query a db using linq to get related rows with a single call?
- C# LINQ NET 3.5 SP1: Using LINQ to group by two fields and assigning a correlative unique ID (integer number) to all member of the group
- How to find all rows of items that have a part in common using LINQ?
- Loading data from three related tables in ASP.NET Core using Entity Framwork Core in one-to-many relationship makes some data not displayed
More Query from same tag
- Is that a shorter way assigning properties with LINQ Query Syntax?
- Using LINQ's Except<> method with an object from an external API
- Linq To Entities - Get User Info With All Roles
- c# one to many string parsing help using regex lambda
- Two different queries - Returning inconsistent results
- C#: LINQ query grouping by multiple columns in data table using Field method
- Select one record using multiple group by and count
- Does .GroupBy() guarantee order in its groupings?
- Fetching the value using Linq
- Linq GroupBy and Lookup<TKey, TElement>.Item
- Iterating through Xdoc decendends adding Xelements
- How to get the "Date" of Max/Min Score with (name, course) group using Linq
- convert sql query to linq with complex left join
- The ':' character, hexadecimal value 0x3A, cannot be included in a name
- Linq Expression Decimal Contains method
- LINQ magic for finding multiple items in a collection without researching for each one?
- How can I add ISortedEnumerable<XElement> to XElement?
- Accessing entities with navigation properties using Linq in Web Api and EF
- 'No generic method > 'OrderByDescending' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments
- The use of where in Linq
- Using Custom Extension Methods inside LinQ (Compare two strings)
- Linq query - reading nested XML to dictionary
- What is the LINQ query to get a Cartesian Product even when one set is EMPTY?
- Inject ViewBag/Razor values onto the page from a List created in the controller
- How to extract child groups from parent and re group using Linq
- Max return value if empty query
- How I get RowNumber with Model In Entity Framework core
- When parse xml via c# get "\ / " or so on
- Question of LINQ optimisation
- MVC5 ICollection<T> remove entity using RemoveAt c# EF 6.1