If your collection type is a
List<stuff>, then the best approach is probably the following:
prods.RemoveAll(s => s.ID == 1)
This only does one pass (iteration) over the list, so should be more efficient than other methods.
If your type is more generically an
ICollection<T>, it might help to write a short extension method if you care about performance. If not, then you’d probably get away with using LINQ (calling
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- Why is .Contains slow? Most efficient way to get multiple entities by primary key?
- Entity Framework/Linq EXpression converting from string to int
- Filter/Search using Multiple Fields – ASP.NET MVC
- How to convert an expression tree to a partial SQL query?
- Join and Include in Entity Framework
- Max return value if empty query
- How to do an “in” query in entity framework?
- LINQ – Full Outer Join
- Group By Multiple Columns
- When to use .First and when to use .FirstOrDefault with LINQ?
- Using LINQ to remove elements from a List
- Decimal precision and scale in EF Code First
- Distinct not working with LINQ to Objects
- Update all objects in a collection using LINQ
- LINQ query on a DataTable
- LINQ – Left Join, Group By, and Count
- What difference does .AsNoTracking() make?
- Bulk-deleting in LINQ to Entities
- Entity Framework – Code First – Can’t Store List
- The type of one of the expressions in the join clause is incorrect in Entity Framework
- Entity framework left join
- Establish a link between two lists in linq to entities where clause
- Value cannot be null. Parameter name: source
- Could not load file or assembly Microsoft.Extensions.DependencyInjection.Abstractions, Version=184.108.40.206
- How to compare only Date without Time in DateTime types in Linq to SQL with Entity Framework?
- Creating dynamic queries with entity framework
- “A lambda expression with a statement body cannot be converted to an expression tree”
- LINQ Grouping dynamically
- Am I misunderstanding LINQ to SQL .AsEnumerable()?
- DbContext discard changes without disposing
- Order by dynamic parameter
- MVC 4 how pass data correctly from controller to view
- Enable Migrations with Context in Separate Assembly?
- LINQ, Unable to create a constant value of type XXX. Only primitive types or enumeration types are supported in this context
- Internal .NET Framework Data Provider error 1025
- EF Data Context – Async/Await & Multithreading
- Does “foreach” cause repeated Linq execution?
- Linq – What is the quickest way to find out deferred execution or not?
- Why would try/finally rather than a “using” statement help avoid a race condition?
- Check if list contains item from other list in EntityFramework
- EF5 Getting this error message: Model compatibility cannot be checked because the database does not contain model metadata
- Find all child controls of specific type using Enumerable.OfType() or LINQ
- Calling a SQL User-defined function in a LINQ query
- Export Model to DataTable
- Group by with multiple columns using lambda
- Get sum of two columns in one LINQ query
- Last and LastOrDefault not supported
- lookup vs. groupby [duplicate]
- A dictionary where value is an anonymous type in C#