diff --git a/net/DevExtreme.AspNet.Data.Tests/PaginateViaPrimaryKeyTests.cs b/net/DevExtreme.AspNet.Data.Tests/PaginateViaPrimaryKeyTests.cs index 26c5f76e..d553a239 100644 --- a/net/DevExtreme.AspNet.Data.Tests/PaginateViaPrimaryKeyTests.cs +++ b/net/DevExtreme.AspNet.Data.Tests/PaginateViaPrimaryKeyTests.cs @@ -93,12 +93,25 @@ public void ActiveForFirstPage() { Assert.Contains(".Select(obj => new AnonType`1", loadOptions.ExpressionLog[0]); } + [Fact] + public void DisabledWithoutTake() { + var loadOptions = new SampleLoadOptions { + SuppressGuardNulls = true, + PaginateViaPrimaryKey = true + }; + + DataSourceLoader.Load(new object[0], loadOptions); + + Assert.NotEmpty(loadOptions.ExpressionLog); + Assert.DoesNotContain(loadOptions.ExpressionLog, line => line.Contains(".Select")); + } + [Fact] public void RequiresPrimaryKey() { var error = Record.Exception(delegate { DataSourceLoader.Load(new string[0], new SampleLoadOptions { PaginateViaPrimaryKey = true, - Skip = 1 + Take = 1 }); }); Assert.True(error is InvalidOperationException); diff --git a/net/DevExtreme.AspNet.Data/DataSourceLoaderImpl.cs b/net/DevExtreme.AspNet.Data/DataSourceLoaderImpl.cs index a5bff384..c14636c1 100644 --- a/net/DevExtreme.AspNet.Data/DataSourceLoaderImpl.cs +++ b/net/DevExtreme.AspNet.Data/DataSourceLoaderImpl.cs @@ -66,7 +66,7 @@ public LoadResult Load() { Expression loadExpr; - if(!deferPaging && Context.PaginateViaPrimaryKey) { + if(!deferPaging && Context.PaginateViaPrimaryKey && Context.Take > 0) { if(!Context.HasPrimaryKey) { throw new InvalidOperationException(nameof(DataSourceLoadOptionsBase.PaginateViaPrimaryKey) + " requires a primary key."