Skip to content

Commit ac3cced

Browse files
PaginateViaPrimaryKey: enable for Skip=0 (#370)
1 parent 9b5bdc8 commit ac3cced

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

net/DevExtreme.AspNet.Data.Tests/PaginateViaPrimaryKeyTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,23 @@ public void MultiKey() {
7474
}
7575

7676
[Fact]
77-
public void NotUsedWoSkip() {
77+
public void ActiveForFirstPage() {
78+
var data = new[] {
79+
new { ID = 123 }
80+
};
81+
7882
var loadOptions = new SampleLoadOptions {
83+
SuppressGuardNulls = true,
84+
PrimaryKey = new[] { "ID" },
7985
PaginateViaPrimaryKey = true,
86+
87+
Skip = 0,
8088
Take = 123
8189
};
8290

83-
DataSourceLoader.Load(new object[0], loadOptions);
91+
DataSourceLoader.Load(data, loadOptions);
8492

85-
Assert.All(
86-
loadOptions.ExpressionLog,
87-
i => Assert.DoesNotContain(".Select(", i)
88-
);
93+
Assert.Contains(".Select(obj => new AnonType`1", loadOptions.ExpressionLog[0]);
8994
}
9095

9196
[Fact]

net/DevExtreme.AspNet.Data/DataSourceLoaderImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public LoadResult Load() {
6666

6767
Expression loadExpr;
6868

69-
if(!deferPaging && Context.PaginateViaPrimaryKey && Context.Skip > 0) {
69+
if(!deferPaging && Context.PaginateViaPrimaryKey) {
7070
if(!Context.HasPrimaryKey) {
7171
throw new InvalidOperationException(nameof(DataSourceLoadOptionsBase.PaginateViaPrimaryKey)
7272
+ " requires a primary key."

0 commit comments

Comments
 (0)