score:9
what you have is correct. this will be translated into an in
clause in sql with the values supplied in the collection.
on an unrelated note, you should try ordering the query by date descending and use firstordefault()
. as it is now, you're going to bring back the entire result set and throw away every row but one.
score:1
this will translate into efficient sql, so there's no need to use anything else.
score:4
you should be careful with such queries with list.contains()
inside of linq query
. because for each list element it will create a param in sql statement
.
and there's a limited number of params allowed in sql statement, <= 2100
.
so if your theids will contains more than 2100
elements it will fail.
if you want to use in this way, you should at least check your theids count
and if more then 2100
dived it in pieces with less then 2100
elements.
Source: stackoverflow.com
Related Query
- How to call an Sql User defined Function using Entity frame work Code first approach with LInq c#
- Using Linq to do a Contains with multiple values
- Why didn't the LINQ designers stick with using the way sql is written today?
- Using LINQ to SQL with Oracle
- Using text SQL with LINQ
- Eager-loading using LINQ to SQL with Include()
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- Expression to get LINQ with Contains to EF for SQL IN() where on entities child's property equals value
- Determine, that sequence contains other sequence, in same order, with using LINQ
- Using Compiled Linq To SQL with ExecuteMethodCall
- Problem with adding record using LINQ to SQL
- What are the prerequisites for using SQL and LINQ with my winforms application in C#?
- Using delete on a LINQ to Sql Data Context with an Interface - 'Interface is not mapped as a table'
- Using LINQ to SQL with Dynamic tables
- Using Field<> with Linq to SQL
- How can I select using LINQ for an entry that contains a LIST with more than one row?
- Reuse Linq to SQL code with entityframework
- how to search string in Linq to SQL using contains
- Linq sub query when using a repository pattern with EF code first
- Linq to sql as object data source - designer problem with partial classes
- Convert SQL - LINQ - Problem with using both Min/Max
- Entity Framework with LINQ using CONTAINS in WHERE clause very slow with large integer list
- Using the equivalent to the SQL IN function with LINQ with a collection
- Is using Linq with Stored Procedure perform better than Linq with Generated SQL ?
- Accessing SQL Server time in code with LINQ
- Linq to SQL using Lambda expressions together with Join, GroupBy, Count and Sum
- Can't add a new record with an integer value into database by using linq from code C#
- Using Attach with Linq To Sql and Stored Procs
- Using SQL Server Filestream with LINQ
- The source contains no DataRows using Linq
More Query from same tag
- Most efficient way to create a dynamic LINQ query that depends on multiple search fields?
- Query with EF 5, Associations VS Linq join
- C# LINQ Help with Errors
- Counting while mapping to an object in a linq subquery
- how to remove elements from xml by index
- How to select items without repetition?
- Order by user and then select max date
- How to filter with Linq
- Selectively remove from where clause in LINQ expression tree
- Default Empty in LINQ not functioned so i need to find what is the problem
- Creating ILookups
- I didn't true use order by in linq
- Convert SQL code to linq (LIKE, SELECT)
- find object from Tree or List Hierarchy
- Linq error "Input string was not in a correct format."
- Obtaining the min and max of a two-dimensional array using LINQ
- How to rewrite this linq query correctly?
- How to check value of item is not equal to zero before adding in a list?
- Sort Generic list of generic objects by multiple values and specific value of generic object
- Linq, why is setting parameter to null returns all rows in the database?
- Fetch records from table in the sequence of provided list in C#
- To convert XElement into int value,
- Trying to use LINQ to check if a BitmapSource exists in a List<BitmapSource>
- Linq SelectMany Usage
- Getting values from JSON objects using LINQ
- How merge two sequences into one?
- Linq to entities - first letter of string between 2 keys
- How to convert List to a string and back
- How to remove duplicates from a List<List<T>> for value types T?
- Get items from a list by ids of another list