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 Query
- 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
More Query from same tag
- How to group inner list data based on a key in outer list in c# linq
- Short Date in Linq
- Instead of FirstOrDefault() what do I use to get all values in group by?
- LINQ Single() Exception for 0 or multiple items
- get items from a list and it's inner list into one list?
- filter by included entities
- How to work with extra int parameter in LINQ Where()
- LINQ Expression Tree: Call Any method against a DbSet
- need to get unmatched records from these 2 lists/tables using linq
- Transforming SQL into Linq To Objects expressions at runtime
- Using strict types in linq grouping query
- How to use properties in Linq to XML
- How to find a match with 2 comma separated strings with LINQ
- LINQ query with value from dropdown to compare with data
- Group DateTime by year and month then order it
- Whats the proper way to check to see if an entry in a db table is null?
- LinQ to XML, selecting a node with 2 levels of search criteria
- LinQ - Error when trying to order by child property
- How can I see the SQL text that is sent by LINQ to my database?
- What is LINQ to events a.k.a RX Framework?
- linq join on null
- Linq. How to query list within list?
- How do you dispose of IDisposableobject create inside of a Linq expression?
- Modify values before inserting through an EntityDataSource Object
- select distinct out of three column connectiontable
- How would I write this to a csv file in c#?
- How much is there to LINQ?
- Cross Join with Where clause
- LINQ - Not returning the same value as SQL Server
- C# LINQ query shows and exception when datagridview cell is empty