score:2
Accepted answer
Move Music music = new Music();
inside your foreach
loop.
At the moment you're creating a single Music
instance and adding it to the list multiple times. Every time you update it, every item in the list is affected because they're all the same item.
Source: stackoverflow.com
Related Articles
- .NET Linq to XML: final value overwrites the previous DISTINCT values
- Replacing values with LINQ in a list with the previous value matching some criterion
- LINQ List overwrites previous value instead of setting new one
- LINQ query to return distinct field values from list of objects
- Why is there no Linq method to return distinct values by a predicate?
- Select All distinct values in a column using LINQ
- LINQ Get Distinct values and fill LIST
- How to get distinct with highest value using Linq
- Select distinct values from a list using LINQ in C#
- LINQ to SQL value BETWEEN two double values
- How do you return a default value if a LINQ to entities query returns no values
- Linq expression to set all values of an array to a given value
- Linq query to get the distinct values in a list
- Linq - select distinct values
- How to get Distinct Values from List(Of T) using Linq
- Get the number of distinct property values in List<T> using LINQ in C#
- C# LINQ Select objects with the same value of one property join values of other
- Select all rows with distinct column value using LINQ
- LINQ Source Code Available
- Count distinct values of a column in dataGridView using linq in .NET
- How can I make my Linq select return values if the value selected is null?
- Ordering Distinct values with LINQ
- Entity Framework / Linq - Get distinct values of dynamically specified property
- Selecting rows with distinct column values using LINQ
- LinQ Sum Distinct Values Quantity and Total
- Linq select distinct values with comparison
- IEqualityComparer and Linq Distinct - Hard Code GetHashCode()
- Linq selecting inner values with distinct
- Linq query distinct values of date for last 7 days, exception thrown when running query
- Get previous value in linq loop?
- How can I select items from a table but ban certain from another?
- InvalidOperationException in release-mode of visual studio since using .Net 4.0
- What would be Linq for Following
- How to create a Dictionary out of two separate lists using linq and lambda expressions
- How to implement Count method on Mocked IQueryable object
- Is it possible to do a linq query on a GridView (ASP.NET)?
- Linq to EF query with criteria filter
- Conditionally allowing for null in LINQ WHERE clause
- How to see Children().ToList() method in JEnumerable<JToken> object?
- Linq: X objects in a row
- How to work with nested Arrays and Objects using LINQ
- Aggregate Multiples using Linq from XML
- Filtering or removing array objects from the DTO class object based on an another list in .net
- How to get total results count before .Take() - but when using .Take()
- How would I write this LINQ query?
- LINQ Sum Nested collection with GroupBy and OrderByDescending
- Implement search in collection with transliteration
- What is the fastest way to get the last elements of a list by ID with Datetime?
- Linq Query Help Needed - Determining Exact Subsets
- LINQ: Group by aggregate but still get information from the most recent row?