todictionary is the way to go. it does work - you were just using it incorrectly, presumably. try this:
dic = dic.where(p => p.key == 1) .todictionary(p => p.key, p => p.value);
having said that, i assume you really want a different
where filter, as your current one will only ever find one key...
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- When using a LINQ Where clause on a Dictionary, how can I return a dictionary of the same type?
- Using Linq to filter out certain Keys from a Dictionary and return a new dictionary
- How can I get the top three players and their high scores from a collection using linq and lambdas
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Can I receive both the return value and resultset from a procedure using Linq to sql?
- How do I group items from a collection using LINQ and return the shaped data according the collection type
- Using Linq to filter out certain Keys from a Dictionary and return a new dictionary2
- Using LINQ and Entity Framework, how can I just populate some properties of a Dbo with data from the DB?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- How can I write the following code more elegantly using LINQ query syntax?
- How can I compare two sets of data in linq and return the common data?
- How can I code an outer join using LINQ and EF6?
- 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?
- How can I use LINQ and C# to find the oldest date from 3 different files?
- How can I use LINQ to filter and sort rows from one collection to another?
- How to iterate a list returned from a Dictionary using Linq and C#
- How can I filter a list using generics and Linq extension methods?
- How to return values from a LINQ query and display them in a table using C#, ASP.NET MVC and Entity Framework
- How to get elements from List<> using Linq and Dictionary in query C#?
- How to get the distinct record name and its each record count to bind to gridview in C# using Linq from SQL Server
- how can I return a certain amount of items from my db using linq statements in c#
- VB.NET and linQ: How to delete entries from a dictionary using the value
- How to get items from SQL, using linq to sql, where Date is from today to 30 days ahead and return as a list
- How can I return a object with the sum of all objects from a list using Linq?
- How to Filter Child Collection from each Parent Entity in the Parent Collection using Linq
- How can I return all the columns of a table using multiple distinct columns in Linq
- how can i filter the Linq results to only return selected XML column
- linq lamba how can i query a list of child properties and return the parent
- How can I filter a nested dictionary using LINQ in C#?
More Query from same tag
- Left join two datatables with certain parameters
- Where to process data? Db or locally?
- How to retrieve data from multiple tables using Entity Framework
- LINQ: Evaluating a function where array elements are matched by index
- Parallel invocation of elements of an IEnumerable
- Unique Values from a list of of items in C#
- Find duplicate objects in list when grouping on one or more fields
- How to Perform ToString On Property of an Entity Framework Model Using Reflection
- Find word before specific phrase in string
- Check if entity implements interface and add predicate in generic repo
- Comparing Integer Array in Linq Query
- Merge Complex Object List using Union / Intersect
- LINQ: Transforming items in a collection
- select A where A < B in LINQ
- Get the count of rows of a DataTable using Linq or without using Linq
- Where clause not entering lambda
- EF and Linq with self referential table
- C# Linq adding to dictionary with list as value
- Compare a Part of the date using linq
- Why does this linq query not give me expected result?
- How to parse CSV that is passed as a parameter to a method
- How to use Include in GroupBy
- Custom And() function for Linq Expressions
- LINQ to intersect elements of complex List<T> into new List<T>
- How to prevent overlapping events using Linq + Entity Framework
- Populate a C# class from a dataset with multiple linked tables using linq lambda
- Difference between List.All() and List.TrueForAll()
- LINQ.Aggregate returning incorrect results
- EF Core Linq Join with OR condition using Method Systax
- How to Compare two dates in LINQ in Entity Framework in .NET 5