score:14
Accepted answer
You need a where, not a select:
var qry = from m in context.Collections
group m by new { m.city, m.name } into grp
where grp.Count() > 1
select grp.Key;
score:0
Building on @Jon Skeet's answer with a "one liner" alternative that returns the duplicate values, not just the keys:
var duplicates = db.Collections.GroupBy(m => new { m.city, m.name })
.Where(a => a.Count() > 1)
.SelectMany(a => a.ToList());
Source: stackoverflow.com
Related Query
- Finding duplicate row using Linq
- How to join one row to every row in source table using LINQ
- getting duplicate rows for each row using linq query
- Finding row in Nested List using LINQ
- Finding duplicate values in row(s) in different tables using linq vb.net
- Convert string[] to int[] in one line of code using LINQ
- LINQ Using Max() to select a single row
- Finding first index of element that matches a condition using LINQ
- Select Multiple elements in a row using Linq
- How to find duplicate record using Linq from DataTable
- Finding Consecutive Items in List using Linq
- Using LINQ to get DataGridView row index where first column has specific value
- Left outer join using LINQ -- understanding the code
- How to reuse a linq expression for 'Where' when using multiple source tables
- Using LINQ to remove any value that is a duplicate
- Avoiding code repetition when using LINQ
- Combine tables using row values as column LINQ C# SQL
- Using LINQ to delete an element from a ObservableCollection Source
- LINQ Source Code Available
- Duplicate rows when using orderby, Skip() and Take() with LINQ
- Finding combinations of a grouped list using LINQ in c#
- Start reading data from a specific row of excel using Linq in C#
- Finding common components using LINQ
- How can I write the following code more elegantly using LINQ query syntax?
- Finding objects which contains at least all elements from subset using RavenDB and LINQ
- Merge duplicate data without affecting others in LINQ code
- How can I code an outer join using LINQ and EF6?
- MVC finding row in database not using primary key
- How do I calculate a checksum on all columns in a row using LINQ and Entity Framework?
- MVC Controller: Using LINQ to check for duplicate value already existing in table before Save?
More Query from same tag
- AutoMapper and convert a datetime to string
- Linq: how return property of specific object
- Filter Data based on same ID
- Change condition in LINQ by another condition
- Write the proper query
- Good Fast Way to Let Users Visualize and Explore Relational Data?
- Dynamically selecting fields in a linq query
- Join two datatable using LINQ and get result in other datatable
- Why can't I use Linq Select in subclass of List<string> using base.Select?
- Proper way of using contain
- Can these for loops be refactored in LINQ?
- Linq to sql, using like in dynamic where clause
- How can I remove all ListItems except the one having a particular value from an ItemList of a drop-down?
- Check if a string has at least one number in it using LINQ
- entity framework - underlying SQL statement
- sum and group by in linq to sql
- Is it possible to group make this with LINQ?
- Unusual error when returning list of results from API
- C# Build where clause dynamically in Linq? for RavenDB
- GetType Of Entity in LINQ Query
- MonogDB C# Driver LINQ query not working when filtering by _id
- How to add objects with Entity Framework without its associated entity duplicated
- String.StartsWith not working with tilde ("~") characters LINQ to SQL?
- How to remove a value from a specific property in a JSON string by matching value?
- How is ParallelEnumerable.Zip() inteded to work, and why does the behavior change when calling AsEnumerable()?
- Using LINQ to flatten lists while capturing the index
- How to use Linq to Xml with several levels in c#
- Using LINQ to remove duplicate content in list?
- How can I create a LINQ statement that does a count of a joined table?
- Using linq to find parent with attribute