score:1
if you have a cars
navigation property in your aspnetuser
entity, you could do this:
var query= await _unit.repository<aspnetuser>()
.queryable()
.where(u=>!u.cars.any(c=>c.id==carid))
.select(c => new customermodel()
{
id = c.id,
email = c.email
})
.tolistasync();
also you can change your where
to .where(u=>u.cars.all(c=>c.id!=carid))
,could be more readable
Source: stackoverflow.com
Related Query
- Linq Entity Framework - get all customers that Ids are not in many to many table
- Entity Framework Linq - how to get groups that contain all your data
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- How to select elements from a table that are present in a junction table with LINQ - Entity Framework
- Use LINQ to get items in one List<>, that are not in another List<>
- Using LINQ to find all keys from one collection that are not in another?
- Entity Framework - Only update values that are not null
- Entity Framework: Get all rows from the table for the ids in list
- Which LINQ query to select rows from 1 table that are not in another table
- linq - how do you do a query for items in one query source that are not in another one?
- Is it possible to get Entity Framework to recognize objects that have been created and not yet saved in database?
- Entity Framework using Sqlite.NET complains that APPLY joins are not supported
- How to write Linq (or lambda) statement to produce all element that are NOT IN (or NOT EXIST)
- Using Join to get the updated Table Linq Entity Framework
- Speed Up Performance - LINQ to get items in one LIST, that are not in another List
- LINQ retrieve values from a table that of which fields(of a certain column) are not equal of another table
- Counting occurrences in a many to many table with Entity framework and LINQ
- Entity Framework Invalid column name when adding property that is not in db table
- Entity Framework Core Linq query returning ids which do not exist in database
- Entity Framework LINQ Get all items part of another collection
- Entity Framework Core 3.1 - Linq - Could not be translated. Either rewrite the query in a form that can be translated
- Get columns values in data table using linq from Entity Framework
- LINQ Unable to get distinct value from many to many Entity Framework
- entity framework linq query, get top N postIDs from favorite's table based on count
- I have Entity Framework 6.2 I am trying to find all columns in a table that have a type of date time
- Linq Join Data Table to Entity Framework - Not Evaluating results
- Linq join does not include data from child table in Entity Framework
- Get days that are not present in a date range using Linq
- Entity Framework 4: SQL to Linq: How to select strings that are not uppercase?
- Get all the variables of a SQL Dataset that are the max of a sort order using LINQ
More Query from same tag
- Is there any applications available to write linq query and execute?
- Convert linq query to string array - C#
- Doing pivot with LINQ
- Linq Min in Select new & Multiple GroupBy columns
- surprising linq except behavior
- Need to Include() related entities but no option to do so
- Filter a certain value in List according to Where using LINQ
- SQL query -> LINQ
- Setting EntitySet<t> properties to default using reflection
- LINQ to Entities only supports casting EDM primitive or enumeration types error
- C# Iterating and Comparing/Identifying WMI Services Effectively
- Querying a nested list using linq
- Parent and collection of child objects
- How to sort a hashtable of class values by their property in c#?
- Group by in linq and show group items that all have the same value of a property
- joining in Linq
- Getting Distinct Values with LINQ
- getting values of DataTable column and putting it into new datatable C# using LINQ
- Entity-framework code is slow when using Include() many times
- Entity Framework Core Linq query returning ids which do not exist in database
- LINQ expression: How to get the most recent results?
- Outer join in linq and get records based on a condition from second table
- Unable to cast an IEnumerable to a known type
- Using LINQ Include after GroupBy and Take
- How to create multiply WHERE (and compare) with LINQ?
- Combining two expressions (Expression<Func<T, bool>>)
- Most efficient way to compare lots variables? C#
- Linq To Entities Query Oddity
- Creating a hierarchical structure from a list of sequence strings
- How to compare dictonary key with xml attribute value in xml using LINQ in c #?