score:2
Accepted answer
You can try to GroupBy
the Country
, SwiftCode
swiftCodeInfo.GroupBy(l => new { l.Country, l.SwiftCode })
.Select(g => new BranchCode {
Country = g.Key.Country,
SwiftCode = g.Key.SwiftCode,
BranchCodes = g.Select(i => i.BranchCode).ToList()
});
Source: stackoverflow.com
Related Articles
- Need to convert a class into another class with distinct value collection
- Cleaner way to convert collection into another type?
- How would I convert List<Dictionary<string, object>> into a List<[new class with dynamic properties]>
- Linq & C# - Inserting distinct data from one class into another
- How to convert Collection of One Class type to Another Class Type collection in Entity Framework
- C# Collection select value of the property with minimum value of another property
- Can't add a new record with an integer value into database by using linq from code C#
- Use LINQ to convert comma separated strings in a table into a distinct collection of values
- Check if all items in a collection with a certain value are all in another collection with Linq?
- LINQ: Load XML into a Dictionary with value equaling new custom class instances
- How to use Linq to select information from a collection into another concrete class I made?
- Find a certain value from a source collection in a target collection of different type with linq
- fill object data source with class in another project
- How to convert data in sql table into datetime and compare with other value in linq
- need to convert sql join query with count into linq and pass it to view
- How to perform .Max() on a property of all objects in a collection and return the object with maximum value
- Distinct by property of class with LINQ
- Split a collection into `n` parts with LINQ?
- LINQ - Convert List to Dictionary with Value as List
- How to convert a List<T> into a comma-separated list, using the class's Id property as the value
- Convert an array to dictionary with value as index of the item and key as the item itself
- Linq to update a collection with values from another collection?
- How to get distinct with highest value using Linq
- Convert or map a list of class to another list of class by using Lambda or LINQ?
- This code returns distinct values. However, what I want is to return a strongly typed collection as opposed to an anonymous type
- How to Convert the value in DataTable into a string array in c#
- How do I convert a single value of type T into an IEnumerable<T>?
- Check if a value is in a collection with LINQ
- LINQ question ... need to get element with min value
- How do I convert IEnumerable to Collection with linq
- Expression `t => (t.SomeProperty As Object)` refers to a method, not a property
- Control not visible even visibility set to visible
- Check if string is GUID in LINQ
- Sum of varchar field in linq , how to do conversion
- Left Join Linq to Entity's Vb.net
- How to use LINQ to retrieve child collection
- How do I count the number of rows that have a value in column "A", but have a different value in column "B" using Linq
- How to convert this LINQ Query result back to DataTable object?
- linq to entities if filter parameter is null then select all entities?
- Linq Conversion From ICollection<T> to List<T>
- Merging 2 dictionaries having duplicate keys with linq
- References an external field in a linq subquery
- In Linq, check child relationships?
- Coverting a foreach loop containing an if statement into linq method syntax in C#
- Casting to custom type, Enumerable.Cast<T> and the as keyword
- How to use/enable LINQ combined with custom serializer? (MONGODB C#)
- Use LINQ to transform single object into IEnumerable via Properties/reflection?
- How to use LINQ to get multiple totals
- Can I get values from my database using this method but without generating the additional text?
- INCLUDE in Linq but to include only some columns from the included object