Skip to content

Commit 8f0aae9

Browse files
Disable PaginateViaPrimaryKey without Take (#375)
1 parent 6d97370 commit 8f0aae9

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,25 @@ public void ActiveForFirstPage() {
9393
Assert.Contains(".Select(obj => new AnonType`1", loadOptions.ExpressionLog[0]);
9494
}
9595

96+
[Fact]
97+
public void DisabledWithoutTake() {
98+
var loadOptions = new SampleLoadOptions {
99+
SuppressGuardNulls = true,
100+
PaginateViaPrimaryKey = true
101+
};
102+
103+
DataSourceLoader.Load(new object[0], loadOptions);
104+
105+
Assert.NotEmpty(loadOptions.ExpressionLog);
106+
Assert.DoesNotContain(loadOptions.ExpressionLog, line => line.Contains(".Select"));
107+
}
108+
96109
[Fact]
97110
public void RequiresPrimaryKey() {
98111
var error = Record.Exception(delegate {
99112
DataSourceLoader.Load(new string[0], new SampleLoadOptions {
100113
PaginateViaPrimaryKey = true,
101-
Skip = 1
114+
Take = 1
102115
});
103116
});
104117
Assert.True(error is InvalidOperationException);

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) {
69+
if(!deferPaging && Context.PaginateViaPrimaryKey && Context.Take > 0) {
7070
if(!Context.HasPrimaryKey) {
7171
throw new InvalidOperationException(nameof(DataSourceLoadOptionsBase.PaginateViaPrimaryKey)
7272
+ " requires a primary key."

0 commit comments

Comments
 (0)