score:0
i think you can query it like this:
var input = new list<string>() // list of ids
list<string> itemsthatexist = new list<string>();
var itemsthatnotexist = await dbcontext.set<data>()
.asqueryable()
.todictionaryasync(_ => _.id, _ => _);
foreach (var item in input)
{
if(allitems.containskey(item)){
itemsthatexist.add(item);
itemsthatnotexist.remove(item);
}
}
score:0
if you don't want to use !contain
you can use logical method as below:
datattable is the content of your table.
list<string> fulllist = new list<string>() { "3", "1", "2" }; //or any dynamic list content or class list based on requirement.
list<string> itemsthatnotexistindb = new list<string>(); //new container list same as fulllist
foreach (var item in fulllist)
{
var isremoved = datatable.removeall(a => a.id == item) == 1 ? true : false;
if (isremoved)
{
itemsthatnotexistindb.add(item);
}
}
Source: stackoverflow.com
Related Query
- Get items from input list that do not exist in the database using EF Core 2.1
- How to get a list of user dialogs from the database of all messages using Entity Framework Core
- Using LINQ in .Net 3.1 to get all items from a database table that matches a list of ID's
- Using Linq, get all items from list that are in another List<int>
- Using LINQ to get a list of items where the item contains a part of an item from another list
- How do I get a list of integers that exist in one collection, but not in another of a different type using LINQ?
- Get a strongly typed list of unique items using LINQ GroupBy() from database
- Get items from list where index not equal to an int using LINQ
- Using LINQ to remove items from a list that do not apear in another list
- Using LINQ and EF, how to remove values from database where not in list of items
- Is there a way to get all the items from a list that have a specific property
- Get the items from a list that match all itens from another list
- How to get duplicate items from a list using LINQ?
- Get specific property from all items from the list
- Remove items from list that intersect on property using Linq
- Get sum of the value from list using linq?
- Using Linq and C#, trying to get two lists from a list of master items grouped by two inner lists
- Select items from a List where the children contain the items from another List using LINQ
- Get the count of distinct elements from a list of lists using LINQ
- How to get items that are and are not in a list
- How do I get the Nth largest element from a list with duplicates, using LINQ?
- Is a full list returned first and then filtered when using linq to sql to filter data from a database or just the filtered list?
- Excluding items from a list that exist in another list
- Get Min and Max for items from database using Linq
- Select items from List A where the property is not in List B
- Get the objects with the maximum value for a specific property from a list using LINQ
- How to get the list elements that are not into another list C#
- Using LINQ to get distinct items that do not join
- How to count the occurence of each number in list A that is exist in list B and return zero if not existed?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
More Query from same tag
- LINQ to Entities does not recognize the method 'Int32 ToInt32(System.Object)' method
- LINQ query on List<T> to get List<U> based on minimum value
- C# LINQ Distinct(f=>f.propertyname) doesnt work
- Creating a map from property names to types with that property
- Generic Method to create Parameterized SQL from a Class
- query xml using xsd attributes
- Linq C# : Integer dbnull value how can I check it?
- The translation of String.IndexOf to SQL does not support versions with a StringComparison argument
- LINQ Get Data from 2 tables in 1 join with group by
- Using LINQ in a List
- Using DateTime.Quarter in LinQ Group
- How to convert a LINQ query back to simple foreach?
- Linq groupby issue
- LINQ group by month question
- How do I return single data from primary table and multiple entries in second table nested after join
- Incrementing an element using LINQ to XML
- Linq query comparison
- LINQ to Entities does not recognize the method 'Single Abs(Single)' method
- LINQ query works agains SQL Server but not Entity Framework/LINQ to SQL
- EF Linq query with conditional include
- IQueryable to List<T>
- DataTable Select vs LINQ Select
- create an xml with Excel
- how to get sum of anonymous field in dynamic linq query
- Add an index to a list to show a ranking from 1 to max items in the list
- ASP.NET How to retrieve a list of the empty labels on a page?
- Type cannot be inferred within a generic delegate
- Linq take returns zero elements from OData collection
- Why Linq can't translate expression/treat as local expression and throws an exception?
- How can I Make a LINQ query expression dynamic