In Linq-to-Entities LINQ queries are translated into SQL queries so Linq-to-Objects implementation of OrderBy doesn't matter. You should look at your database implementation of ORDER BY. If you are using MS SQL you can find in docs that:
To achieve stable results between query requests using OFFSET and FETCH, the following conditions must be met: (...)
- The ORDER BY clause contains a column or combination of columns that are guaranteed to be unique.
So ORDER BY for the same values does not guarantee the same order so limiting it could provide different results set. To solve this you can simply sort by some additional column that has unique values e.g. id. So basically you will have:
var result = data .OrderBy(i => i.TimeStamp) .ThenBy(i => i.Id) .Skip(start) .Take(length);
I take it that by "stable", you mean consistent. If you didn't have the ORDER BY in a SQL query, the order of the data is not guaranteed for each time you run the query. It will simply return all of the data in whatever order is most efficient for the server. When you add the ORDER BY, it will sort that data. Since you are sorting data where all of the sort values are the same, no rows are being reordered, so the ordered data is in an order you don't expect. If you need a specific order, you will need to add a secondary sort column such as an ID.
It is a best to never assume the order of data coming back from the server unless you explicitly define what that order is.
- SQL Server Database is not updated via C# Code
- Can't find OrderBy on Queryable with the "supplied arguments".
- Picking random record from Entity Framework database without OrderBy
- Check LINQ query against SQL Server database
- How to validate LINQ queryable without database
- LINQ Source Code Available
- multiple orderby in this linq code
- .NET 4 Code Contracts: "requires unproven: source != null"
- orderby certain property - code improvement
- If all my sql server database access is done thru stored procedures
- LINQ Lambda efficiency of code groupby orderby
- EF Code first Eager loading and OrderBy problem
- Export SQL Server Database Table to XML Using Linq
- creating Linq to sqlite dbml from DbLinq source code
- LINQ code to combine two database tables?
- Issue on delete record from SQL Server database through C# program
- updating data in many-to-many relationship in entity framework in code first existing database
- What is better way to update SQL Server database using Linq?
- Windows Phone SQL Server CE - Retrieve underlying database schema for upgrade
- Handling very large strings between SQL Server and .NET code +LINQ
- Fastest way to fetch huge amount of data from SQL Server database
- Pulling a table from a SQL Server database into a List<> in C# using Entity Framework
- linq to entities changing database connection string in code
- How to get Database names from given Sql Server in LINQ
- Updating front-end WPF app from a SQL Server database
- Accessing SQL Server time in code with LINQ
- Distance Calculation with huge SQL Server database
- Is Queryable.OrderBy unstable for SQL Server database?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Is DB_LINQ + Non-SQL Server Database an acceptable substitute for LINQ to SQL with SQL Server?
- Getting today, past, and tomorrows list of appointments
- Read from XML to an object using LINQ
- InvalidCastException in a LINQ query
- How to perform left outer join in Linq
- Call Length Property on Returned Array in Chained String/LINQ Methods of C#
- How do I write a linq to sql query to find records where field name can match one of dynamic number of strings?
- How to Implement GetEnumerator method for class that implements IEnumerable<IEnumerable<T>>
- How to convert a list<string> or list<object> to a ListView.ListViewItemCollection in one line
- Simple linq question: How to filter a source afterwards?
- LINQ remove overlaps of datetime that are common in 2 lists
- Remove specific element from the list
- Update List of objects based on matching type in Dictionary and another List using C# collection
- How to write this query in LINQ?
- Cannot find specific XML elements in XML Document
- How to convert these SQL queries to linq?
- Building OR expressions in the WHERE clause with Linq
- The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities. MVC User Profile Advice
- Converting data from one class to another
- XDocument to dataSet, my nested nodes are getting treated as new tables?