score:3
Accepted answer
you can do that with:
where updatedObjects.Any(uo => uo.ID == o.ID)
score:0
You should be looking to implement batch updates with linq for example like it's described at http://www.aneyfamily.com/terryandann/post/2008/04/Batch-Updates-and-Deletes-with-LINQ-to-SQL.aspx
score:0
You could create a lambda or another method that performs the check for you; for example
where IDMatches(o.ID, updatedObjects)
and then define IDMatches as a simple iteration over updatedObjects.
static void IDMatches(int id, List<MyObject> updatedObjects)
{
foreach (MyObject updated in updatedObjects)
{
if (id == updated.ID)
return true;
}
return false;
}
Source: stackoverflow.com
Related Query
- Using LINQ in an Update Method - trouble with where clause
- Linq with where clause in many-to-many EF Code First object
- C# - Linq optimize code with List and Where clause
- Entity Framework with LINQ using CONTAINS in WHERE clause very slow with large integer list
- Conditionally Insert Where Clause in LINQ Method Syntax with Select Many
- Using switch-case with string in Linq where clause
- Can a LINQ extension method create a new KeyValuePair with a new() .Value when a Where clause isn't satisfied
- Using Trim in multiple where clause of linq with Join clause
- Using Linq to query Entity Framework with Where clause and many-to-many relation
- Issue with Object returned when using Linq Where clause
- LINQ where clause using Generic IQueryable source
- Adding AND in a WHERE clause using ViewBag and SelectList with LINQ in Controller (ASP.Net MVC)
- C# Using Linq Query with where clause as variable on dataTable
- linq groupjoin using lambda with a where clause
- Trouble With Linq Where Clause
- LINQ - Where clause with Boolean method
- LINQ Using inline subquery with min() in a left join where clause
- Entity Framework dynamic linq where from generic source with dynamic where clause
- How do you perform a left outer join with a where clause using linq lambda extension methods
- VB net & Mongo: Using where clause with LINQ causes error "Unsupported where clause: (Boolean)Operators.CompareObjectLess"
- Convert T-SQL to LINQ using the WHERE IN clause with a Nested Subquery
- using Linq with multiple where conditions
- Update XML with C# using Linq
- Using my own method with LINQ to Entities
- two conditions checking in where clause using linq 2 entites
- Linq Query with a Where clause in an Include statement
- How to update an element with a List using LINQ and C#
- Equivalence of query and method (lambda) syntax of a Join with Where clause
- Why C# LINQ expressions must end with Select or Group By Clause where as no such restriction in VB.Net
- LINQ Where clause with Contains where the list has complex object
More Query from same tag
- LINQ navigation property multiple sources
- What is the purpose of 'var'?
- C# How to sort a list of objects by any property
- How to Filter DataGridView when bound to a linq query result that is linked to an EF4 Entity
- How to use Ternary operation for Linq insertion from form Correctly
- LINQ/Dictionary Connecting two methods into a single one
- non executing linq causing memory allocation C#
- Linq with inner join and grouping
- Find missing required values in a List
- c# wpf filter list In Statement
- How do tsql query in linq
- JSON Encode and Decode with objects in Visual Basic 2010
- How to call a method in Linq query?
- SQL GROUP BY with MAX as Linq?
- LINQ distinct by 2 properties and by create date
- How do I pass column values from multiple tables to the view in MVC?
- How to translate SQL to LINQ?
- SQL Server: Access Fulltext Index via LINQ
- enumerated more than once in linq to sql stored procedure call
- Convert codes to faster codes using Groupby
- Linq, join, group, count > select more values
- How can I convert my working SQL query to Linq (C#)?
- LINQ to SQL where clause verifying string contains list element
- Linq query from c# to VB.NET
- Is there way to use Distinct in LINQ query syntax?
- filtering XML nodes containing a greater-than character in node text
- LINQ gives different results against XML and Db
- How can i Join, GroupBy and Select with LINQ?
- LINQ to return distinct value by specific column
- LINQ - Inserts not working with "junction" table