score:3
Accepted answer
Sounds like you probably want:
var next = table.Where(item => item.id > lastId &&
item.projects_ID == projects_ID &&
item.language == language)
.OrderBy(item => item.id)
.FirstOrDefault();
Or as a query expression:
var next = (from item in table
where item.id > lastId &&
item.projects_ID == projects_ID &&
item.language == language
orderby item.id
select item).FirstOrDefault();
The result will be null
if there are no matches (e.g. if you're already looking at the last ID). This is assuming by "next" you mean "matching item with the lowest ID greater than the current one".
Source: stackoverflow.com
Related Articles
- LINQ Query - Get the next row with matching parameters
- linq to sql query with multiple where parameters
- Entity Framework with Oracle using odp.net not taking parameters in linq query
- LINQ Filter query with multiple optional parameters
- LINQ select next record with each matching result
- Linq sub query when using a repository pattern with EF code first
- .NET LINQ Call Method with Out Parameters Within Query and use Out Values
- Query with LINQ where Context matches multiple parameters from a List of Objects
- LINQ Query with two COUNTs based on different parameters in Where statement
- Avoiding repeating code with Linq query + optional params
- Linq query to db with dynamic where parameters
- How to write a LINQ query to select from a collection with given set of matching IDs
- LINQ custom class query with parameters select
- query entity with linq passing in two parameters
- how to write a Linq query with a EF code first Many to Many relationship
- How to query two tables for matching values with linq and C#?
- Indirection with linq : Change query expression "Select" according users parameters
- Get next element from Query after element with specified Id. The LINQ expression could not be translated
- Search query with parameters in linq c#
- Is it right a LINQ query to check whether atleast one entity exists in string collection with a matching criteria (rownum<=1)
- Creating LINQ query with two parameters
- Proper Linq Query for objects with many to many relation ship generated with code first entity framework
- Creating LINQ query with DISTINCT, OFFSET and FETCH NEXT
- Linq query to take the value from Array with matching sub string value
- Linq query with nullable sum
- Problem with linq query
- Nested "from" LINQ query expressed with extension methods
- How to use index/position with Where in LINQ query language?
- Linq query with Array in where clause?
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- Trim whitespace from DataTable cells with Linq
- C# LINQ: How is string("[1, 2, 3]") parsed as an array?
- LINQ Query over heterogeneous collection of different types with same base class
- add MAX to existing criteria in LINQ query
- Linq select with join
- How make condition the elements in two arrays, Linq c#
- linq query with parameter which can be empty
- Fastest algorithm to compare two collections or list
- Linq To Xml Null Checking of attributes
- Parallel inner join
- LINQ to objects cast result of query
- Dictionary<something, List<>> flatten (ungroup) to List of something and elements from List - C#
- C# Convert Nullable DateTime in String with mask into Select New
- Get distinct items by combination from list C#
- Linq Distinct with a single comparison class (and interface)
- C# + LINQ + ADO.NET EF , join 2 tables and return everything without specifying all fields manually
- LINQ Checking all Records in Group
- Simulating Cross Context Joins--LINQ/C#
- Perform LINQ join with two conditions
- Linq to NHibernate generating multiple joins to the same table