├── .gitattributes ├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── AgGrid.InfiniteRowModel.sln ├── LICENSE ├── README.md ├── sample └── AgGrid.InfiniteRowModel.Sample │ ├── .gitignore │ ├── AgGrid.InfiniteRowModel.Sample.csproj │ ├── ClientApp │ ├── .editorconfig │ ├── .gitignore │ ├── angular.json │ ├── browserslist │ ├── e2e │ │ ├── protractor.conf.js │ │ ├── src │ │ │ ├── app.e2e-spec.ts │ │ │ └── app.po.ts │ │ └── tsconfig.e2e.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── app │ │ │ ├── ag-boolean-column-filter │ │ │ │ ├── ag-boolean-column-filter.component.html │ │ │ │ ├── ag-boolean-column-filter.component.ts │ │ │ │ └── boolean-filter.model.ts │ │ │ ├── app.component.html │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ ├── app.server.module.ts │ │ │ ├── infinite-row-model-result.model.ts │ │ │ ├── user.model.ts │ │ │ └── user.service.ts │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── index.html │ │ ├── karma.conf.js │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── styles.css │ │ ├── test.ts │ │ ├── tsconfig.app.json │ │ ├── tsconfig.server.json │ │ ├── tsconfig.spec.json │ │ └── tslint.json │ ├── tsconfig.json │ └── tslint.json │ ├── Controllers │ └── UsersController.cs │ ├── Database │ ├── AppDbContext.cs │ └── Seeder.cs │ ├── Entities │ └── User.cs │ ├── Migrations │ ├── 20210411190148_Initial.Designer.cs │ ├── 20210411190148_Initial.cs │ ├── 20210412152216_AddIsVerifiedColumn.Designer.cs │ ├── 20210412152216_AddIsVerifiedColumn.cs │ └── AppDbContextModelSnapshot.cs │ ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ └── _ViewImports.cshtml │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ └── favicon.ico ├── src ├── AgGrid.InfiniteRowModel.EntityFrameworkCore │ ├── AgGrid.InfiniteRowModel.EntityFrameworkCore.csproj │ └── QueryableExtensions.cs └── AgGrid.InfiniteRowModel │ ├── AgGrid.InfiniteRowModel.csproj │ ├── GetRowsParams.cs │ ├── InfiniteRowModelOptions.cs │ ├── InfiniteRowModelResult.cs │ ├── InfiniteScroll.cs │ ├── QueryableExtensions.cs │ └── StringExtensions.cs └── tests └── AgGrid.InfiniteRowModel.Tests ├── AgGrid.InfiniteRowModel.Tests.csproj ├── Async.cs ├── Filtering.cs ├── InMemory.cs ├── Models └── UserDto.cs ├── NHibernate.cs ├── Ordering.cs ├── Paging.cs ├── Parsing.cs ├── PostgreSQL.cs ├── SqlServer.cs ├── Sqlite.cs └── Validation.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/sample/AgGrid.InfiniteRowModel.Sample/bin/Debug/net5.0/AgGrid.InfiniteRowModel.Sample.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/sample/AgGrid.InfiniteRowModel.Sample", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach" 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "angular.view-engine": true 3 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/sample/AgGrid.InfiniteRowModel.Sample/AgGrid.InfiniteRowModel.Sample.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/sample/AgGrid.InfiniteRowModel.Sample/AgGrid.InfiniteRowModel.Sample.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/sample/AgGrid.InfiniteRowModel.Sample/AgGrid.InfiniteRowModel.Sample.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /AgGrid.InfiniteRowModel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{2BEC35D9-2519-4406-BE1E-7E1B320EF34B}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0BBD24C7-9802-47D9-B84C-1203DEF1FE2C}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgGrid.InfiniteRowModel.Sample", "sample\AgGrid.InfiniteRowModel.Sample\AgGrid.InfiniteRowModel.Sample.csproj", "{4A11AEB9-D343-4DD6-A64B-1E8379904D85}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgGrid.InfiniteRowModel", "src\AgGrid.InfiniteRowModel\AgGrid.InfiniteRowModel.csproj", "{74AD98E5-8A82-4AC9-9531-B80915463B2D}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{62D44B2A-2545-402C-BF3F-479510BFD2F4}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgGrid.InfiniteRowModel.Tests", "tests\AgGrid.InfiniteRowModel.Tests\AgGrid.InfiniteRowModel.Tests.csproj", "{CDE5B4A7-075F-4041-8F46-780EC489C8F9}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgGrid.InfiniteRowModel.EntityFrameworkCore", "src\AgGrid.InfiniteRowModel.EntityFrameworkCore\AgGrid.InfiniteRowModel.EntityFrameworkCore.csproj", "{9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {4A11AEB9-D343-4DD6-A64B-1E8379904D85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {4A11AEB9-D343-4DD6-A64B-1E8379904D85}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {4A11AEB9-D343-4DD6-A64B-1E8379904D85}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {4A11AEB9-D343-4DD6-A64B-1E8379904D85}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {74AD98E5-8A82-4AC9-9531-B80915463B2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {74AD98E5-8A82-4AC9-9531-B80915463B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {74AD98E5-8A82-4AC9-9531-B80915463B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {74AD98E5-8A82-4AC9-9531-B80915463B2D}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {CDE5B4A7-075F-4041-8F46-780EC489C8F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {CDE5B4A7-075F-4041-8F46-780EC489C8F9}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {CDE5B4A7-075F-4041-8F46-780EC489C8F9}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {CDE5B4A7-075F-4041-8F46-780EC489C8F9}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(NestedProjects) = preSolution 47 | {4A11AEB9-D343-4DD6-A64B-1E8379904D85} = {2BEC35D9-2519-4406-BE1E-7E1B320EF34B} 48 | {74AD98E5-8A82-4AC9-9531-B80915463B2D} = {0BBD24C7-9802-47D9-B84C-1203DEF1FE2C} 49 | {CDE5B4A7-075F-4041-8F46-780EC489C8F9} = {62D44B2A-2545-402C-BF3F-479510BFD2F4} 50 | {9A28C0D8-FEA2-40D5-AF24-F20BB2B7BA08} = {0BBD24C7-9802-47D9-B84C-1203DEF1FE2C} 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {D4F544CC-1E0D-4E1D-AE74-4142B12074D0} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Adrian Wilczyński 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AG Grid Infinite Row Model for ASP.NET Core & EF Core 2 | 3 | AG Grid's [Infinite Row Model](https://www.ag-grid.com/javascript-grid/infinite-scrolling/) (infinite scroll) 4 | for Entity Framework Core implemented with `System.Linq.Dynamic`. 5 | 6 | ## How to use? 7 | 8 | - Add `AgGrid.InfiniteRowModel` (or `AgGrid.InfiniteRowModel.EntityFrameworkCore` for async methods) package to your ASP.NET Core project. 9 | - Call `GetInfiniteRowModelBlock` extension method on chosen `DbSet`/`IQueryable` and pass `IGetRowsParams` (without `context`) from AG Grid's `datasource`. You can pass deserialized object (of type `GetRowsParams`) or JSON string. 10 | - Pass the result (`rowsThisBlock` and `lastRow`) to `successCallback` of your `datasource` (see sample code below). 11 | 12 | *More in `sample/AgGrid.InfiniteRowModel.Sample`* 13 | 14 | ```csharp 15 | [HttpGet] 16 | public InfiniteRowModelResult Get(string query) 17 | { 18 | return _dbContext.Users.GetInfiniteRowModelBlock(query); 19 | } 20 | ``` 21 | 22 | ```ts 23 | nullFilterOption: IFilterOptionDef = { 24 | displayKey: 'null', 25 | displayName: 'Null', 26 | test: (filterValues, cellValue) => cellValue === null, 27 | numberOfInputs: 0 28 | }; 29 | 30 | gridOptions: GridOptions = { 31 | defaultColDef: { 32 | sortable: true, 33 | floatingFilter: true 34 | }, 35 | frameworkComponents: { 36 | 'agBooleanColumnFilter': AgBooleanColumnFilterComponent 37 | }, 38 | columnDefs: [ 39 | { 40 | headerName: 'Full name', 41 | field: 'fullName', 42 | filter: 'agTextColumnFilter', 43 | filterParams: { 44 | filterOptions: ['equals', 'notEqual', 'contains', 'notContains', 'startsWith', 'endsWith', this.nullFilterOption ] 45 | } 46 | }, 47 | { headerName: 'Registered on', field: 'registeredOn', filter: 'agDateColumnFilter' }, 48 | { headerName: 'Age', field: 'age', filter: 'agNumberColumnFilter' }, 49 | { headerName: 'Is verified', field: 'isVerified', filter: 'agBooleanColumnFilter' } 50 | ], 51 | rowModelType: 'infinite', 52 | datasource: { 53 | getRows: (params: IGetRowsParams) => { 54 | this.userService.getUsers(JSON.stringify(params)) 55 | .subscribe( 56 | result => params.successCallback(result.rowsThisBlock, result.lastRow), 57 | () => params.failCallback()); 58 | } 59 | } 60 | }; 61 | ``` 62 | 63 | ```ts 64 | getUsers(query: string): Observable> { 65 | return this.httpClient.get>(this.baseUrl + 'api/Users', { 66 | params: { 67 | query: query 68 | } 69 | }); 70 | } 71 | ``` 72 | 73 | ## Supported filters 74 | 75 | This package supports all three [built-in simple filters](https://www.ag-grid.com/angular-data-grid/filter-provided-simple/): 76 | - Text Filter, 77 | - Number Filter, 78 | - Date Filter. 79 | 80 | You can use [custom filter option](https://www.ag-grid.com/angular-data-grid/filter-provided-simple/#custom-filter-options) with simple filters to allow filtering by null. 81 | 82 | It also provides support for [custom boolean filter](https://www.ag-grid.com/angular-data-grid/component-filter/) implementation. You don't have to use the same filter but your filter model has to match `BooleanFilterModel` interface (below). 83 | 84 | ```ts 85 | @Component({ 86 | selector: 'app-ag-boolean-column-filter', 87 | templateUrl: './ag-boolean-column-filter.component.html', 88 | providers: [ 89 | { provide: MAT_CHECKBOX_CLICK_ACTION, useValue: 'noop' } 90 | ] 91 | }) 92 | export class AgBooleanColumnFilterComponent implements AgFilterComponent { 93 | private params: IFilterParams; 94 | 95 | value: boolean | null = null; 96 | 97 | agInit(params: IFilterParams): void { 98 | this.params = params; 99 | } 100 | 101 | onCheckboxClicked(): void { 102 | if (this.value === null) { 103 | this.value = true; 104 | } else if (this.value === true) { 105 | this.value = false; 106 | } else if (this.value === false) { 107 | this.value = null; 108 | } 109 | 110 | this.updateFilter(); 111 | } 112 | 113 | isFilterActive(): boolean { 114 | return this.value !== null; 115 | } 116 | 117 | doesFilterPass(params: IDoesFilterPassParams): boolean { 118 | throw new Error(`Not implemented. Seems to be unnecessary since we're doing all our filtering on the server side.`); 119 | } 120 | 121 | getModel(): BooleanFilterModel { 122 | if (!this.isFilterActive()) { 123 | return null; 124 | } 125 | 126 | return { 127 | filter: this.value, 128 | filterType: 'boolean', 129 | type: 'equals' 130 | }; 131 | } 132 | 133 | setModel(model: BooleanFilterModel) { 134 | if (!model) { 135 | this.value = null; 136 | return; 137 | } 138 | 139 | this.value = model.filter; 140 | } 141 | 142 | updateFilter() { 143 | this.params.filterChangedCallback(); 144 | } 145 | 146 | getModelAsString(): string { 147 | return this.value.toString(); 148 | } 149 | } 150 | ``` 151 | ```html 152 |
153 | 154 | 155 |
156 | ``` 157 | 158 | ```ts 159 | export interface BooleanFilterModel { 160 | filter: boolean; 161 | filterType: 'boolean'; 162 | type: 'equals' | 'notEqual'; 163 | } 164 | ``` 165 | 166 | ## How to run sample app? 167 | 168 | - Just run it. Database will be created and seeded on app startup. 169 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | bin/ 23 | Bin/ 24 | obj/ 25 | Obj/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | *_i.c 44 | *_p.c 45 | *_i.h 46 | *.ilk 47 | *.meta 48 | *.obj 49 | *.pch 50 | *.pdb 51 | *.pgc 52 | *.pgd 53 | *.rsp 54 | *.sbr 55 | *.tlb 56 | *.tli 57 | *.tlh 58 | *.tmp 59 | *.tmp_proj 60 | *.log 61 | *.vspscc 62 | *.vssscc 63 | .builds 64 | *.pidb 65 | *.svclog 66 | *.scc 67 | 68 | # Chutzpah Test files 69 | _Chutzpah* 70 | 71 | # Visual C++ cache files 72 | ipch/ 73 | *.aps 74 | *.ncb 75 | *.opendb 76 | *.opensdf 77 | *.sdf 78 | *.cachefile 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | *.sap 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | nCrunchTemp_* 110 | 111 | # MightyMoose 112 | *.mm.* 113 | AutoTest.Net/ 114 | 115 | # Web workbench (sass) 116 | .sass-cache/ 117 | 118 | # Installshield output folder 119 | [Ee]xpress/ 120 | 121 | # DocProject is a documentation generator add-in 122 | DocProject/buildhelp/ 123 | DocProject/Help/*.HxT 124 | DocProject/Help/*.HxC 125 | DocProject/Help/*.hhc 126 | DocProject/Help/*.hhk 127 | DocProject/Help/*.hhp 128 | DocProject/Help/Html2 129 | DocProject/Help/html 130 | 131 | # Click-Once directory 132 | publish/ 133 | 134 | # Publish Web Output 135 | *.[Pp]ublish.xml 136 | *.azurePubxml 137 | # TODO: Comment the next line if you want to checkin your web deploy settings 138 | # but database connection strings (with potential passwords) will be unencrypted 139 | *.pubxml 140 | *.publishproj 141 | 142 | # NuGet Packages 143 | *.nupkg 144 | # The packages folder can be ignored because of Package Restore 145 | **/packages/* 146 | # except build/, which is used as an MSBuild target. 147 | !**/packages/build/ 148 | # Uncomment if necessary however generally it will be regenerated when needed 149 | #!**/packages/repositories.config 150 | 151 | # Microsoft Azure Build Output 152 | csx/ 153 | *.build.csdef 154 | 155 | # Microsoft Azure Emulator 156 | ecf/ 157 | rcf/ 158 | 159 | # Microsoft Azure ApplicationInsights config file 160 | ApplicationInsights.config 161 | 162 | # Windows Store app package directory 163 | AppPackages/ 164 | BundleArtifacts/ 165 | 166 | # Visual Studio cache files 167 | # files ending in .cache can be ignored 168 | *.[Cc]ache 169 | # but keep track of directories ending in .cache 170 | !*.[Cc]ache/ 171 | 172 | # Others 173 | ClientBin/ 174 | ~$* 175 | *~ 176 | *.dbmdl 177 | *.dbproj.schemaview 178 | *.pfx 179 | *.publishsettings 180 | orleans.codegen.cs 181 | 182 | /node_modules 183 | 184 | # RIA/Silverlight projects 185 | Generated_Code/ 186 | 187 | # Backup & report files from converting an old project file 188 | # to a newer Visual Studio version. Backup files are not needed, 189 | # because we have git ;-) 190 | _UpgradeReport_Files/ 191 | Backup*/ 192 | UpgradeLog*.XML 193 | UpgradeLog*.htm 194 | 195 | # SQL Server files 196 | *.mdf 197 | *.ldf 198 | 199 | # Business Intelligence projects 200 | *.rdl.data 201 | *.bim.layout 202 | *.bim_*.settings 203 | 204 | # Microsoft Fakes 205 | FakesAssemblies/ 206 | 207 | # GhostDoc plugin setting file 208 | *.GhostDoc.xml 209 | 210 | # Node.js Tools for Visual Studio 211 | .ntvs_analysis.dat 212 | 213 | # Visual Studio 6 build log 214 | *.plg 215 | 216 | # Visual Studio 6 workspace options file 217 | *.opt 218 | 219 | # Visual Studio LightSwitch build output 220 | **/*.HTMLClient/GeneratedArtifacts 221 | **/*.DesktopClient/GeneratedArtifacts 222 | **/*.DesktopClient/ModelManifest.xml 223 | **/*.Server/GeneratedArtifacts 224 | **/*.Server/ModelManifest.xml 225 | _Pvt_Extensions 226 | 227 | # Paket dependency manager 228 | .paket/paket.exe 229 | 230 | # FAKE - F# Make 231 | .fake/ 232 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/AgGrid.InfiniteRowModel.Sample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | true 6 | Latest 7 | false 8 | ClientApp\ 9 | $(DefaultItemExcludes);$(SpaRoot)node_modules\** 10 | 11 | 12 | false 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | all 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | %(DistFiles.Identity) 60 | PreserveNewest 61 | true 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | 15 | [*.{razor,cshtml}] 16 | charset = utf-8-bom 17 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /dist-server 6 | /tmp 7 | /out-tsc 8 | 9 | # dependencies 10 | /node_modules 11 | 12 | # IDEs and editors 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | *.sublime-workspace 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | yarn-error.log 35 | testem.log 36 | /typings 37 | 38 | # System Files 39 | .DS_Store 40 | Thumbs.db 41 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "AgGrid.InfiniteRowModel.Sample": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "progress": false, 17 | "extractCss": true, 18 | "outputPath": "dist", 19 | "index": "src/index.html", 20 | "main": "src/main.ts", 21 | "polyfills": "src/polyfills.ts", 22 | "tsConfig": "src/tsconfig.app.json", 23 | "assets": [ 24 | "src/assets" 25 | ], 26 | "styles": [ 27 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 28 | "node_modules/bootstrap/dist/css/bootstrap.min.css", 29 | "src/styles.css" 30 | ], 31 | "scripts": [] 32 | }, 33 | "configurations": { 34 | "production": { 35 | "fileReplacements": [ 36 | { 37 | "replace": "src/environments/environment.ts", 38 | "with": "src/environments/environment.prod.ts" 39 | } 40 | ], 41 | "optimization": true, 42 | "outputHashing": "all", 43 | "sourceMap": false, 44 | "extractCss": true, 45 | "namedChunks": false, 46 | "aot": true, 47 | "extractLicenses": true, 48 | "vendorChunk": false, 49 | "buildOptimizer": true 50 | } 51 | } 52 | }, 53 | "serve": { 54 | "builder": "@angular-devkit/build-angular:dev-server", 55 | "options": { 56 | "browserTarget": "AgGrid.InfiniteRowModel.Sample:build" 57 | }, 58 | "configurations": { 59 | "production": { 60 | "browserTarget": "AgGrid.InfiniteRowModel.Sample:build:production" 61 | } 62 | } 63 | }, 64 | "extract-i18n": { 65 | "builder": "@angular-devkit/build-angular:extract-i18n", 66 | "options": { 67 | "browserTarget": "AgGrid.InfiniteRowModel.Sample:build" 68 | } 69 | }, 70 | "test": { 71 | "builder": "@angular-devkit/build-angular:karma", 72 | "options": { 73 | "main": "src/test.ts", 74 | "polyfills": "src/polyfills.ts", 75 | "tsConfig": "src/tsconfig.spec.json", 76 | "karmaConfig": "src/karma.conf.js", 77 | "styles": [ 78 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 79 | "src/styles.css" 80 | ], 81 | "scripts": [], 82 | "assets": [ 83 | "src/assets" 84 | ] 85 | } 86 | }, 87 | "lint": { 88 | "builder": "@angular-devkit/build-angular:tslint", 89 | "options": { 90 | "tsConfig": [ 91 | "src/tsconfig.app.json", 92 | "src/tsconfig.spec.json" 93 | ], 94 | "exclude": [ 95 | "**/node_modules/**" 96 | ] 97 | } 98 | }, 99 | "server": { 100 | "builder": "@angular-devkit/build-angular:server", 101 | "options": { 102 | "outputPath": "dist-server", 103 | "main": "src/main.ts", 104 | "tsConfig": "src/tsconfig.server.json" 105 | }, 106 | "configurations": { 107 | "dev": { 108 | "optimization": true, 109 | "outputHashing": "all", 110 | "sourceMap": false, 111 | "namedChunks": false, 112 | "extractLicenses": true, 113 | "vendorChunk": true 114 | }, 115 | "production": { 116 | "optimization": true, 117 | "outputHashing": "all", 118 | "sourceMap": false, 119 | "namedChunks": false, 120 | "extractLicenses": true, 121 | "vendorChunk": false 122 | } 123 | } 124 | } 125 | } 126 | }, 127 | "AgGrid.InfiniteRowModel.Sample-e2e": { 128 | "root": "e2e/", 129 | "projectType": "application", 130 | "architect": { 131 | "e2e": { 132 | "builder": "@angular-devkit/build-angular:protractor", 133 | "options": { 134 | "protractorConfig": "e2e/protractor.conf.js", 135 | "devServerTarget": "AgGrid.InfiniteRowModel.Sample:serve" 136 | } 137 | }, 138 | "lint": { 139 | "builder": "@angular-devkit/build-angular:tslint", 140 | "options": { 141 | "tsConfig": "e2e/tsconfig.e2e.json", 142 | "exclude": [ 143 | "**/node_modules/**" 144 | ] 145 | } 146 | } 147 | } 148 | } 149 | }, 150 | "defaultProject": "AgGrid.InfiniteRowModel.Sample" 151 | } -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require("jasmine-spec-reporter"); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: ["./src/**/*.e2e-spec.ts"], 9 | capabilities: { 10 | browserName: "chrome" 11 | }, 12 | directConnect: true, 13 | baseUrl: "http://localhost:4200/", 14 | framework: "jasmine", 15 | jasmineNodeOpts: { 16 | showColors: true, 17 | defaultTimeoutInterval: 30000, 18 | print: function() {} 19 | }, 20 | onPrepare() { 21 | require("ts-node").register({ 22 | project: require("path").join(__dirname, "./tsconfig.e2e.json") 23 | }); 24 | jasmine 25 | .getEnv() 26 | .addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getMainHeading()).toEqual('Hello, world!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getMainHeading() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aggrid.infiniterowmodel.sample", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "build:ssr": "ng run AgGrid.InfiniteRowModel.Sample:server:dev", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "8.2.12", 16 | "@angular/cdk": "~8.2.3", 17 | "@angular/common": "8.2.12", 18 | "@angular/compiler": "8.2.12", 19 | "@angular/core": "8.2.12", 20 | "@angular/forms": "8.2.12", 21 | "@angular/material": "^8.2.3", 22 | "@angular/platform-browser": "8.2.12", 23 | "@angular/platform-browser-dynamic": "8.2.12", 24 | "@angular/platform-server": "8.2.12", 25 | "@angular/router": "8.2.12", 26 | "@nguniversal/module-map-ngfactory-loader": "8.1.1", 27 | "ag-grid-angular": "^25.1.0", 28 | "ag-grid-community": "^25.1.0", 29 | "aspnet-prerendering": "^3.0.1", 30 | "bootstrap": "^4.3.1", 31 | "core-js": "^3.3.3", 32 | "jquery": "3.4.1", 33 | "oidc-client": "^1.9.1", 34 | "popper.js": "^1.16.0", 35 | "rxjs": "^6.5.3", 36 | "zone.js": "0.9.1" 37 | }, 38 | "devDependencies": { 39 | "@angular-devkit/build-angular": "^0.803.26", 40 | "@angular/cli": "^8.3.26", 41 | "@angular/compiler-cli": "^8.2.14", 42 | "@angular/language-service": "^8.2.12", 43 | "@types/jasmine": "~3.4.4", 44 | "@types/jasminewd2": "~2.0.8", 45 | "@types/node": "~12.11.6", 46 | "codelyzer": "^5.2.0", 47 | "jasmine-core": "~3.5.0", 48 | "jasmine-spec-reporter": "~4.2.1", 49 | "karma": "^5.0.2", 50 | "karma-chrome-launcher": "~3.1.0", 51 | "karma-coverage-istanbul-reporter": "~2.1.0", 52 | "karma-jasmine": "~2.0.1", 53 | "karma-jasmine-html-reporter": "^1.4.2", 54 | "typescript": "3.5.3" 55 | }, 56 | "optionalDependencies": { 57 | "node-sass": "^4.12.0", 58 | "protractor": "~5.4.2", 59 | "ts-node": "~8.4.1", 60 | "tslint": "~5.20.0" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/ag-boolean-column-filter/ag-boolean-column-filter.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/ag-boolean-column-filter/ag-boolean-column-filter.component.ts: -------------------------------------------------------------------------------- 1 | import { AgFilterComponent } from 'ag-grid-angular'; 2 | import { IDoesFilterPassParams, IFilterParams } from 'ag-grid-community'; 3 | import { Component } from '@angular/core'; 4 | import { BooleanFilterModel } from './boolean-filter.model'; 5 | import { MAT_CHECKBOX_CLICK_ACTION } from '@angular/material'; 6 | 7 | @Component({ 8 | selector: 'app-ag-boolean-column-filter', 9 | templateUrl: './ag-boolean-column-filter.component.html', 10 | providers: [ 11 | { provide: MAT_CHECKBOX_CLICK_ACTION, useValue: 'noop' } 12 | ] 13 | }) 14 | export class AgBooleanColumnFilterComponent implements AgFilterComponent { 15 | private params: IFilterParams; 16 | 17 | value: boolean | null = null; 18 | 19 | agInit(params: IFilterParams): void { 20 | this.params = params; 21 | } 22 | 23 | onCheckboxClicked(): void { 24 | if (this.value === null) { 25 | this.value = true; 26 | } else if (this.value === true) { 27 | this.value = false; 28 | } else if (this.value === false) { 29 | this.value = null; 30 | } 31 | 32 | this.updateFilter(); 33 | } 34 | 35 | isFilterActive(): boolean { 36 | return this.value !== null; 37 | } 38 | 39 | doesFilterPass(params: IDoesFilterPassParams): boolean { 40 | throw new Error(`Not implemented. Seems to be unnecessary since we're doing all our filtering on the server side.`); 41 | } 42 | 43 | getModel(): BooleanFilterModel { 44 | if (!this.isFilterActive()) { 45 | return null; 46 | } 47 | 48 | return { 49 | filter: this.value, 50 | filterType: 'boolean', 51 | type: 'equals' 52 | }; 53 | } 54 | 55 | setModel(model: BooleanFilterModel) { 56 | if (!model) { 57 | this.value = null; 58 | return; 59 | } 60 | 61 | this.value = model.filter; 62 | } 63 | 64 | updateFilter() { 65 | this.params.filterChangedCallback(); 66 | } 67 | 68 | getModelAsString(): string { 69 | return this.value.toString(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/ag-boolean-column-filter/boolean-filter.model.ts: -------------------------------------------------------------------------------- 1 | export interface BooleanFilterModel { 2 | filter: boolean; 3 | filterType: 'boolean'; 4 | type: 'equals' | 'notEqual'; 5 | } 6 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { GridOptions, IFilterOptionDef, IGetRowsParams } from 'ag-grid-community'; 3 | import { AgBooleanColumnFilterComponent } from './ag-boolean-column-filter/ag-boolean-column-filter.component'; 4 | import { UserService } from './user.service'; 5 | 6 | @Component({ 7 | selector: 'app-root', 8 | templateUrl: './app.component.html' 9 | }) 10 | export class AppComponent { 11 | constructor(private userService: UserService) { } 12 | 13 | nullFilterOption: IFilterOptionDef = { 14 | displayKey: 'null', 15 | displayName: 'Null', 16 | test: (filterValue, cellValue) => cellValue === null, 17 | hideFilterInput: true 18 | }; 19 | 20 | notNullFilterOption: IFilterOptionDef = { 21 | displayKey: 'notNull', 22 | displayName: 'Not null', 23 | test: (filterValue, cellValue) => cellValue !== null, 24 | hideFilterInput: true 25 | }; 26 | 27 | gridOptions: GridOptions = { 28 | defaultColDef: { 29 | sortable: true, 30 | floatingFilter: true 31 | }, 32 | frameworkComponents: { 33 | 'agBooleanColumnFilter': AgBooleanColumnFilterComponent 34 | }, 35 | columnDefs: [ 36 | { 37 | headerName: 'Full name', 38 | field: 'fullName', 39 | filter: 'agTextColumnFilter', 40 | filterParams: { 41 | filterOptions: [ 42 | 'equals', 'notEqual', 'contains', 'notContains', 'startsWith', 'endsWith', 43 | this.nullFilterOption, this.notNullFilterOption 44 | ] 45 | } 46 | }, 47 | { headerName: 'Registered on', field: 'registeredOn', filter: 'agDateColumnFilter', sort: 'desc' }, 48 | { headerName: 'Age', field: 'age', filter: 'agNumberColumnFilter' }, 49 | { headerName: 'Is verified', field: 'isVerified', filter: 'agBooleanColumnFilter' } 50 | ], 51 | rowModelType: 'infinite', 52 | datasource: { 53 | getRows: (params: IGetRowsParams) => { 54 | console.log(JSON.stringify(params, null, 4)); 55 | 56 | this.userService.getUsers(JSON.stringify(params)) 57 | .subscribe( 58 | result => params.successCallback(result.rowsThisBlock, result.lastRow), 59 | () => params.failCallback()); 60 | } 61 | } 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http'; 5 | import { RouterModule } from '@angular/router'; 6 | import { AgGridModule } from 'ag-grid-angular'; 7 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 8 | import { MatCheckboxModule } from '@angular/material/checkbox'; 9 | 10 | import { AppComponent } from './app.component'; 11 | import { AgBooleanColumnFilterComponent } from './ag-boolean-column-filter/ag-boolean-column-filter.component'; 12 | 13 | @NgModule({ 14 | declarations: [ 15 | AppComponent, 16 | AgBooleanColumnFilterComponent 17 | ], 18 | imports: [ 19 | BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }), 20 | HttpClientModule, 21 | FormsModule, 22 | RouterModule.forRoot([]), 23 | AgGridModule.withComponents([AgBooleanColumnFilterComponent]), 24 | NoopAnimationsModule, 25 | MatCheckboxModule 26 | ], 27 | providers: [], 28 | bootstrap: [AppComponent] 29 | }) 30 | export class AppModule { } 31 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/app.server.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { ServerModule } from '@angular/platform-server'; 3 | import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader'; 4 | import { AppComponent } from './app.component'; 5 | import { AppModule } from './app.module'; 6 | 7 | @NgModule({ 8 | imports: [AppModule, ServerModule, ModuleMapLoaderModule], 9 | bootstrap: [AppComponent] 10 | }) 11 | export class AppServerModule { } 12 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/infinite-row-model-result.model.ts: -------------------------------------------------------------------------------- 1 | export interface InfiniteRowModelResult { 2 | rowsThisBlock: T[]; 3 | lastRow?: number; 4 | } -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/user.model.ts: -------------------------------------------------------------------------------- 1 | export interface User { 2 | id: number; 3 | fullName: string; 4 | registeredOn: string; 5 | age: number; 6 | isVerified: boolean; 7 | } 8 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/app/user.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Inject, Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { InfiniteRowModelResult } from './infinite-row-model-result.model'; 5 | import { User } from './user.model'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class UserService { 11 | constructor(private httpClient: HttpClient, @Inject('BASE_URL') private baseUrl: string) { } 12 | 13 | getUsers(query: string): Observable> { 14 | return this.httpClient.get>(this.baseUrl + 'api/Users', { 15 | params: { 16 | query: query 17 | } 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrianWilczynski/AgGrid.InfiniteRowModel/4057b4bdb53c996209f082aa00020d0b6679bc34/sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/assets/.gitkeep -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | AgGrid.InfiniteRowModel.Sample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Loading... 17 | 18 | 19 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | export function getBaseUrl() { 8 | return document.getElementsByTagName('base')[0].href; 9 | } 10 | 11 | const providers = [ 12 | { provide: 'BASE_URL', useFactory: getBaseUrl, deps: [] } 13 | ]; 14 | 15 | if (environment.production) { 16 | enableProdMode(); 17 | } 18 | 19 | platformBrowserDynamic(providers).bootstrapModule(AppModule) 20 | .catch(err => console.log(err)); 21 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/styles.css: -------------------------------------------------------------------------------- 1 | @import "~ag-grid-community/dist/styles/ag-grid.css"; 2 | @import "~ag-grid-community/dist/styles/ag-theme-material.css"; 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "src/test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/tsconfig.server.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "commonjs" 5 | }, 6 | "angularCompilerOptions": { 7 | "entryModule": "app/app.server.module#AppServerModule" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "module": "esnext", 6 | "outDir": "./dist/out-tsc", 7 | "sourceMap": true, 8 | "declaration": false, 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es2015", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2017", 18 | "dom" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/ClientApp/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-shadowed-variable": true, 69 | "no-string-literal": false, 70 | "no-string-throw": true, 71 | "no-switch-case-fall-through": true, 72 | "no-trailing-whitespace": true, 73 | "no-unnecessary-initializer": true, 74 | "no-unused-expression": true, 75 | "no-use-before-declare": true, 76 | "no-var-keyword": true, 77 | "object-literal-sort-keys": false, 78 | "one-line": [ 79 | true, 80 | "check-open-brace", 81 | "check-catch", 82 | "check-else", 83 | "check-whitespace" 84 | ], 85 | "prefer-const": true, 86 | "quotemark": [ 87 | true, 88 | "single" 89 | ], 90 | "radix": true, 91 | "semicolon": [ 92 | true, 93 | "always" 94 | ], 95 | "triple-equals": [ 96 | true, 97 | "allow-null-check" 98 | ], 99 | "typedef-whitespace": [ 100 | true, 101 | { 102 | "call-signature": "nospace", 103 | "index-signature": "nospace", 104 | "parameter": "nospace", 105 | "property-declaration": "nospace", 106 | "variable-declaration": "nospace" 107 | } 108 | ], 109 | "unified-signatures": true, 110 | "variable-name": false, 111 | "whitespace": [ 112 | true, 113 | "check-branch", 114 | "check-decl", 115 | "check-operator", 116 | "check-separator", 117 | "check-type" 118 | ], 119 | "no-output-on-prefix": true, 120 | "no-inputs-metadata-property": true, 121 | "no-outputs-metadata-property": true, 122 | "no-host-metadata-property": true, 123 | "no-input-rename": true, 124 | "no-output-rename": true, 125 | "use-lifecycle-interface": true, 126 | "use-pipe-transform-interface": true, 127 | "component-class-suffix": true, 128 | "directive-class-suffix": true 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.EntityFrameworkCore; 2 | using AgGrid.InfiniteRowModel.Sample.Database; 3 | using AgGrid.InfiniteRowModel.Sample.Entities; 4 | using Bogus; 5 | using Bogus.Extensions; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.EntityFrameworkCore; 8 | using System; 9 | using System.Threading.Tasks; 10 | 11 | namespace AgGrid.InfiniteRowModel.Sample.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class UsersController : ControllerBase 16 | { 17 | private readonly AppDbContext _dbContext; 18 | 19 | public UsersController(AppDbContext dbContext) 20 | { 21 | _dbContext = dbContext; 22 | } 23 | 24 | [HttpGet] 25 | public async Task> Get(string query) 26 | { 27 | return await _dbContext.Users 28 | .AsNoTracking() 29 | .GetInfiniteRowModelBlockAsync(query); 30 | } 31 | 32 | [HttpPost] 33 | public async Task Add() 34 | { 35 | var user = new Faker() 36 | .RuleFor(u => u.RegisteredOn, _ => DateTime.Now) 37 | .RuleFor(u => u.FullName, f => f.Name.FullName().OrNull(f, 0.2f)) 38 | .RuleFor(u => u.Age, f => f.Random.Number(10, 90)) 39 | .RuleFor(u => u.IsVerified, f => f.Random.Bool()) 40 | .Generate(); 41 | 42 | _dbContext.Users.Add(user); 43 | await _dbContext.SaveChangesAsync(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Database/AppDbContext.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace AgGrid.InfiniteRowModel.Sample.Database 5 | { 6 | public class AppDbContext : DbContext 7 | { 8 | public AppDbContext(DbContextOptions options) : base(options) { } 9 | 10 | public DbSet Users { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Database/Seeder.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Entities; 2 | using Bogus; 3 | using Bogus.Extensions; 4 | using Microsoft.EntityFrameworkCore; 5 | using System.Linq; 6 | 7 | namespace AgGrid.InfiniteRowModel.Sample.Database 8 | { 9 | public class Seeder 10 | { 11 | private readonly AppDbContext _dbContext; 12 | 13 | public Seeder(AppDbContext dbContext) 14 | { 15 | _dbContext = dbContext; 16 | } 17 | 18 | public void Seed() 19 | { 20 | _dbContext.Database.Migrate(); 21 | 22 | if (_dbContext.Users.Any()) 23 | { 24 | return; 25 | } 26 | 27 | var faker = new Faker() 28 | .RuleFor(u => u.FullName, f => f.Name.FullName().OrNull(f, 0.2f)) 29 | .RuleFor(u => u.RegisteredOn, f => f.Date.Past(10)) 30 | .RuleFor(u => u.Age, f => f.Random.Number(10, 90)) 31 | .RuleFor(u => u.IsVerified, f => f.Random.Bool()); 32 | 33 | var users = faker.Generate(1000); 34 | 35 | _dbContext.Users.AddRange(users); 36 | _dbContext.SaveChanges(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Entities/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AgGrid.InfiniteRowModel.Sample.Entities 4 | { 5 | public class User 6 | { 7 | public virtual int Id { get; set; } 8 | public virtual string FullName { get; set; } 9 | public virtual DateTime RegisteredOn { get; set; } 10 | public virtual int Age { get; set; } 11 | public virtual bool IsVerified { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Migrations/20210411190148_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using AgGrid.InfiniteRowModel.Sample.Database; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Migrations; 8 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 9 | 10 | namespace AgGrid.InfiniteRowModel.Sample.Migrations 11 | { 12 | [DbContext(typeof(AppDbContext))] 13 | [Migration("20210411190148_Initial")] 14 | partial class Initial 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 21 | .HasAnnotation("ProductVersion", "5.0.5") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("AgGrid.InfiniteRowModel.Sample.Entities.User", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int") 29 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 30 | 31 | b.Property("Age") 32 | .HasColumnType("int"); 33 | 34 | b.Property("FullName") 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("RegisteredOn") 38 | .HasColumnType("datetime2"); 39 | 40 | b.HasKey("Id"); 41 | 42 | b.ToTable("Users"); 43 | }); 44 | #pragma warning restore 612, 618 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Migrations/20210411190148_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace AgGrid.InfiniteRowModel.Sample.Migrations 5 | { 6 | public partial class Initial : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "Users", 12 | columns: table => new 13 | { 14 | Id = table.Column(type: "int", nullable: false) 15 | .Annotation("SqlServer:Identity", "1, 1"), 16 | FullName = table.Column(type: "nvarchar(max)", nullable: true), 17 | RegisteredOn = table.Column(type: "datetime2", nullable: false), 18 | Age = table.Column(type: "int", nullable: false) 19 | }, 20 | constraints: table => 21 | { 22 | table.PrimaryKey("PK_Users", x => x.Id); 23 | }); 24 | } 25 | 26 | protected override void Down(MigrationBuilder migrationBuilder) 27 | { 28 | migrationBuilder.DropTable( 29 | name: "Users"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Migrations/20210412152216_AddIsVerifiedColumn.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using AgGrid.InfiniteRowModel.Sample.Database; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Migrations; 8 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 9 | 10 | namespace AgGrid.InfiniteRowModel.Sample.Migrations 11 | { 12 | [DbContext(typeof(AppDbContext))] 13 | [Migration("20210412152216_AddIsVerifiedColumn")] 14 | partial class AddIsVerifiedColumn 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 21 | .HasAnnotation("ProductVersion", "5.0.5") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("AgGrid.InfiniteRowModel.Sample.Entities.User", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int") 29 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 30 | 31 | b.Property("Age") 32 | .HasColumnType("int"); 33 | 34 | b.Property("FullName") 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("IsVerified") 38 | .HasColumnType("bit"); 39 | 40 | b.Property("RegisteredOn") 41 | .HasColumnType("datetime2"); 42 | 43 | b.HasKey("Id"); 44 | 45 | b.ToTable("Users"); 46 | }); 47 | #pragma warning restore 612, 618 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Migrations/20210412152216_AddIsVerifiedColumn.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace AgGrid.InfiniteRowModel.Sample.Migrations 4 | { 5 | public partial class AddIsVerifiedColumn : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "IsVerified", 11 | table: "Users", 12 | type: "bit", 13 | nullable: false, 14 | defaultValue: false); 15 | } 16 | 17 | protected override void Down(MigrationBuilder migrationBuilder) 18 | { 19 | migrationBuilder.DropColumn( 20 | name: "IsVerified", 21 | table: "Users"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Migrations/AppDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using AgGrid.InfiniteRowModel.Sample.Database; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | namespace AgGrid.InfiniteRowModel.Sample.Migrations 10 | { 11 | [DbContext(typeof(AppDbContext))] 12 | partial class AppDbContextModelSnapshot : ModelSnapshot 13 | { 14 | protected override void BuildModel(ModelBuilder modelBuilder) 15 | { 16 | #pragma warning disable 612, 618 17 | modelBuilder 18 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 19 | .HasAnnotation("ProductVersion", "5.0.5") 20 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 21 | 22 | modelBuilder.Entity("AgGrid.InfiniteRowModel.Sample.Entities.User", b => 23 | { 24 | b.Property("Id") 25 | .ValueGeneratedOnAdd() 26 | .HasColumnType("int") 27 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 28 | 29 | b.Property("Age") 30 | .HasColumnType("int"); 31 | 32 | b.Property("FullName") 33 | .HasColumnType("nvarchar(max)"); 34 | 35 | b.Property("IsVerified") 36 | .HasColumnType("bit"); 37 | 38 | b.Property("RegisteredOn") 39 | .HasColumnType("datetime2"); 40 | 41 | b.HasKey("Id"); 42 | 43 | b.ToTable("Users"); 44 | }); 45 | #pragma warning restore 612, 618 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace AgGrid.InfiniteRowModel.Sample.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | public class ErrorModel : PageModel 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public string RequestId { get; set; } 23 | 24 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 25 | 26 | public void OnGet() 27 | { 28 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using AgGrid.InfiniteRowModel.Sample 2 | @namespace AgGrid.InfiniteRowModel.Sample.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Program.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace AgGrid.InfiniteRowModel.Sample 7 | { 8 | public static class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | var host = CreateHostBuilder(args).Build(); 13 | 14 | using (var scope = host.Services.CreateScope()) 15 | { 16 | var seeder = scope.ServiceProvider.GetRequiredService(); 17 | seeder.Seed(); 18 | } 19 | 20 | host.Run(); 21 | } 22 | 23 | public static IHostBuilder CreateHostBuilder(string[] args) => 24 | Host.CreateDefaultBuilder(args) 25 | .ConfigureWebHostDefaults(webBuilder => 26 | { 27 | webBuilder.UseStartup(); 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:62041", 7 | "sslPort": 44368 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "AgGrid.InfiniteRowModel.Sample": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/Startup.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.AspNetCore.SpaServices.AngularCli; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using System; 10 | 11 | namespace AgGrid.InfiniteRowModel.Sample 12 | { 13 | public class Startup 14 | { 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public IConfiguration Configuration { get; } 21 | 22 | public void ConfigureServices(IServiceCollection services) 23 | { 24 | services.AddControllersWithViews(); 25 | 26 | services.AddSpaStaticFiles(configuration => configuration.RootPath = "ClientApp/dist"); 27 | 28 | services.AddDbContext(options => 29 | options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")) 30 | .LogTo(Console.WriteLine)); 31 | 32 | services.AddTransient(); 33 | 34 | services.AddSwaggerDocument(); 35 | } 36 | 37 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 38 | { 39 | if (env.IsDevelopment()) 40 | { 41 | app.UseDeveloperExceptionPage(); 42 | } 43 | else 44 | { 45 | app.UseExceptionHandler("/Error"); 46 | app.UseHsts(); 47 | } 48 | 49 | app.UseHttpsRedirection(); 50 | app.UseStaticFiles(); 51 | 52 | if (!env.IsDevelopment()) 53 | { 54 | app.UseSpaStaticFiles(); 55 | } 56 | 57 | app.UseOpenApi(); 58 | app.UseSwaggerUi3(); 59 | 60 | app.UseRouting(); 61 | 62 | app.UseEndpoints(endpoints => 63 | { 64 | endpoints.MapControllerRoute( 65 | name: "default", 66 | pattern: "{controller}/{action=Index}/{id?}"); 67 | }); 68 | 69 | app.UseSpa(spa => 70 | { 71 | spa.Options.SourcePath = "ClientApp"; 72 | 73 | if (env.IsDevelopment()) 74 | { 75 | spa.UseAngularCliServer(npmScript: "start"); 76 | } 77 | }); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=AgGridInfiniteRowModelSample;Trusted_Connection=True;" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /sample/AgGrid.InfiniteRowModel.Sample/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrianWilczynski/AgGrid.InfiniteRowModel/4057b4bdb53c996209f082aa00020d0b6679bc34/sample/AgGrid.InfiniteRowModel.Sample/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel.EntityFrameworkCore/AgGrid.InfiniteRowModel.EntityFrameworkCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.1 5 | Adrian Wilczyński 6 | Async support for AgGrid.InfiniteRowModel. 7 | https://github.com/AdrianWilczynski/AgGrid.InfiniteRowModel 8 | 1.6.0 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel.EntityFrameworkCore/QueryableExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using System; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace AgGrid.InfiniteRowModel.EntityFrameworkCore 7 | { 8 | public static class QueryableExtensions 9 | { 10 | public static async Task> GetInfiniteRowModelBlockAsync(this IQueryable queryable, string getRowsParamsJson, InfiniteRowModelOptions options = null) 11 | => await GetInfiniteRowModelBlockAsync(queryable, InfiniteScroll.DeserializeGetRowsParams(getRowsParamsJson), options); 12 | 13 | public static async Task> GetInfiniteRowModelBlockAsync(this IQueryable queryable, GetRowsParams getRowsParams, InfiniteRowModelOptions options = null) 14 | { 15 | var rows = await InfiniteScroll.ToQueryableRows(queryable, getRowsParams, options).ToListAsync(); 16 | return InfiniteScroll.ToRowModelResult(getRowsParams, rows); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/AgGrid.InfiniteRowModel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.1 5 | 9.0 6 | Adrian Wilczyński 7 | AG Grid's Infinite Row Model (infinite scroll) for Entity Framework Core implemented with System.Linq.Dynamic. 8 | https://github.com/AdrianWilczynski/AgGrid.InfiniteRowModel 9 | 1.6.0 10 | true 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/GetRowsParams.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace AgGrid.InfiniteRowModel 5 | { 6 | public class GetRowsParams 7 | { 8 | public int StartRow { get; set; } 9 | public int EndRow { get; set; } 10 | public IEnumerable SortModel { get; set; } = Enumerable.Empty(); 11 | public IDictionary FilterModel { get; set; } = new Dictionary(); 12 | } 13 | 14 | public class SortModel 15 | { 16 | public string Sort { get; set; } 17 | public string ColId { get; set; } 18 | } 19 | 20 | public static class SortModelSortDirection 21 | { 22 | public static HashSet All { get; } = new() { Ascending, Descending }; 23 | 24 | public const string Ascending = "asc"; 25 | public const string Descending = "desc"; 26 | } 27 | 28 | public class FilterModel 29 | { 30 | public string FilterType { get; set; } 31 | public string Type { get; set; } 32 | 33 | public object Filter { get; set; } 34 | public double FilterTo { get; set; } 35 | public string DateFrom { get; set; } 36 | public string DateTo { get; set; } 37 | public IEnumerable Values { get; set; } 38 | 39 | public string Operator { get; set; } 40 | public FilterModel Condition1 { get; set; } 41 | public FilterModel Condition2 { get; set; } 42 | } 43 | 44 | public static class FilterModelFilterType 45 | { 46 | public static HashSet All { get; } = new() { Text, Number, Date, Boolean, Set }; 47 | 48 | public const string Text = "text"; 49 | public const string Number = "number"; 50 | public const string Date = "date"; 51 | public const string Boolean = "boolean"; 52 | public const string Set = "set"; 53 | } 54 | 55 | public static class FilterModelType 56 | { 57 | public static HashSet All { get; } = new() 58 | { 59 | Equals, NotEqual, Contains, NotContains, 60 | StartsWith, EndsWith, LessThan, LessThanOrEqual, 61 | GreaterThan, GreaterThanOrEqual, InRange, 62 | Null, NotNull 63 | }; 64 | 65 | new public const string Equals = "equals"; 66 | public const string NotEqual = "notEqual"; 67 | 68 | public const string Contains = "contains"; 69 | public const string NotContains = "notContains"; 70 | 71 | public const string StartsWith = "startsWith"; 72 | public const string EndsWith = "endsWith"; 73 | 74 | public const string LessThan = "lessThan"; 75 | public const string LessThanOrEqual = "lessThanOrEqual"; 76 | 77 | public const string GreaterThan = "greaterThan"; 78 | public const string GreaterThanOrEqual = "greaterThanOrEqual"; 79 | 80 | public const string InRange = "inRange"; 81 | 82 | public const string Null = "null"; 83 | public const string NotNull = "notNull"; 84 | } 85 | 86 | public static class FilterModelOperator 87 | { 88 | public static HashSet All { get; } = new() { And, Or }; 89 | 90 | public const string And = "AND"; 91 | public const string Or = "OR"; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/InfiniteRowModelOptions.cs: -------------------------------------------------------------------------------- 1 | namespace AgGrid.InfiniteRowModel 2 | { 3 | public class InfiniteRowModelOptions 4 | { 5 | public bool CaseInsensitive { get; set; } 6 | public bool InRangeExclusive { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/InfiniteRowModelResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace AgGrid.InfiniteRowModel 4 | { 5 | public class InfiniteRowModelResult 6 | { 7 | public IEnumerable RowsThisBlock { get; set; } 8 | public int? LastRow { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/InfiniteScroll.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Linq.Dynamic.Core; 6 | using System.Runtime.CompilerServices; 7 | using System.Text.Json; 8 | 9 | [assembly: InternalsVisibleToAttribute("AgGrid.InfiniteRowModel.EntityFrameworkCore")] 10 | namespace AgGrid.InfiniteRowModel 11 | { 12 | internal static class InfiniteScroll 13 | { 14 | public static GetRowsParams DeserializeGetRowsParams(string json) 15 | => JsonSerializer.Deserialize(json, new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 16 | 17 | public static IQueryable ToQueryableRows(IQueryable queryable, GetRowsParams getRowsParams, InfiniteRowModelOptions options) 18 | { 19 | options ??= new InfiniteRowModelOptions(); 20 | 21 | ValidateColIds(getRowsParams); 22 | 23 | return queryable 24 | .Filter(getRowsParams, options) 25 | .Sort(getRowsParams) 26 | .Skip(getRowsParams.StartRow) 27 | .Take(TakeCount(getRowsParams) + 1); 28 | } 29 | 30 | public static InfiniteRowModelResult ToRowModelResult(GetRowsParams getRowsParams, List rows) 31 | { 32 | var reachedEnd = rows.Count <= TakeCount(getRowsParams); 33 | 34 | return new InfiniteRowModelResult 35 | { 36 | RowsThisBlock = rows.Take(TakeCount(getRowsParams)).ToList(), 37 | LastRow = reachedEnd ? getRowsParams.StartRow + rows.Count : null 38 | }; 39 | } 40 | 41 | private static int TakeCount(GetRowsParams getRowsParams) 42 | => getRowsParams.EndRow - getRowsParams.StartRow; 43 | 44 | private static void ValidateColIds(GetRowsParams getRowsParams) 45 | { 46 | var propertyNames = GetPropertyNames(); 47 | var invalidColIds = GetColIds(getRowsParams).Where(c => !propertyNames.Contains(c.ToPascalCase())); 48 | 49 | if (invalidColIds.Any()) 50 | { 51 | throw new ArgumentException($"Invalid colIds: {string.Join(", ", invalidColIds)}."); 52 | } 53 | } 54 | 55 | private static HashSet GetPropertyNames() 56 | => typeof(T).GetProperties().Select(p => p.Name).ToHashSet(); 57 | 58 | private static IEnumerable GetColIds(GetRowsParams getRowsParams) 59 | => getRowsParams.FilterModel.Select(f => f.Key); 60 | 61 | private static IQueryable Filter(this IQueryable queryable, GetRowsParams getRowsParams, InfiniteRowModelOptions options) 62 | { 63 | foreach (var kvp in getRowsParams.FilterModel) 64 | { 65 | var colId = kvp.Key; 66 | var filterModel = kvp.Value; 67 | 68 | if (string.IsNullOrEmpty(filterModel.Operator)) 69 | { 70 | var predicate = GetPredicate(colId, filterModel, 0, options); 71 | var args = GetWhereArgs(colId, filterModel, options); 72 | 73 | queryable = queryable.Where(predicate, args); 74 | } 75 | else 76 | { 77 | ValidateOperator(filterModel); 78 | 79 | var predicateLeftSide = GetPredicate(colId, filterModel.Condition1, 0, options); 80 | var argsLeftSide = GetWhereArgs(colId, filterModel.Condition1, options); 81 | 82 | var rightSideArgsIndex = argsLeftSide.Length; 83 | 84 | var predicateRightSide = GetPredicate(colId, filterModel.Condition2, rightSideArgsIndex, options); 85 | var argsRightSide = GetWhereArgs(colId, filterModel.Condition2, options); 86 | 87 | var predicate = $"({predicateLeftSide}) {filterModel.Operator} ({predicateRightSide})"; 88 | var args = argsLeftSide.Concat(argsRightSide).ToArray(); 89 | 90 | queryable = queryable.Where(predicate, args); 91 | } 92 | } 93 | 94 | return queryable; 95 | } 96 | 97 | private static void ValidateOperator(FilterModel filterModel) 98 | { 99 | if (!FilterModelOperator.All.Contains(filterModel.Operator)) 100 | { 101 | throw new ArgumentException($"Unsupported {nameof(FilterModel.Operator)} value ({filterModel.Operator}). Supported values: {string.Join(", ", FilterModelOperator.All)}."); 102 | } 103 | } 104 | 105 | private static object[] GetWhereArgs(string colId, FilterModel filterModel, InfiniteRowModelOptions options) 106 | { 107 | return filterModel switch 108 | { 109 | { Type: FilterModelType.Null or FilterModelType.NotNull } => Array.Empty(), 110 | 111 | { FilterType: FilterModelFilterType.Text } when options.CaseInsensitive => new object[] { GetString(filterModel.Filter).ToLower() }, 112 | { FilterType: FilterModelFilterType.Text } => new object[] { GetString(filterModel.Filter) }, 113 | 114 | { FilterType: FilterModelFilterType.Number, Type: FilterModelType.InRange } => new object[] { GetNumber(filterModel.Filter), filterModel.FilterTo }, 115 | { FilterType: FilterModelFilterType.Number } => new object[] { GetNumber(filterModel.Filter) }, 116 | 117 | { FilterType: FilterModelFilterType.Date, Type: FilterModelType.InRange } => new object[] { GetDate(filterModel.DateFrom), GetDate(filterModel.DateTo) }, 118 | { FilterType: FilterModelFilterType.Date } => new object[] { GetDate(filterModel.DateFrom) }, 119 | 120 | { FilterType: FilterModelFilterType.Boolean } => new object[] { GetBoolean(filterModel.Filter) }, 121 | 122 | { FilterType: FilterModelFilterType.Set } when options.CaseInsensitive => new object[] { filterModel.Values.Select(v => v?.ToLower()).ToList() }, 123 | { FilterType: FilterModelFilterType.Set } => new object[] { filterModel.Values }, 124 | 125 | _ => throw new ArgumentException($"Unable to determine predicate arguments for {colId}. Most likely {nameof(FilterModel.FilterType)} value ({filterModel.FilterType}) is unsupported. Supported values: {string.Join(", ", FilterModelFilterType.All)}.") 126 | }; 127 | } 128 | 129 | private static string GetString(object element) 130 | => (element as JsonElement?)?.GetString() ?? (string)element; 131 | 132 | private static double GetNumber(object element) 133 | => (element as JsonElement?)?.GetDouble() ?? Convert.ToDouble(element); 134 | 135 | private static DateTime GetDate(string dateString) 136 | => DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); 137 | 138 | private static bool GetBoolean(object element) 139 | => (element as JsonElement?)?.GetBoolean() ?? (bool)element; 140 | 141 | private static string GetPredicate(string colId, FilterModel filterModel, int index, InfiniteRowModelOptions options) 142 | { 143 | var propertyName = colId.ToPascalCase(); 144 | 145 | return filterModel switch 146 | { 147 | { Type: FilterModelType.Equals, FilterType: FilterModelFilterType.Text } when options.CaseInsensitive => $"{propertyName}.ToLower() == @{index}", 148 | { Type: FilterModelType.Equals } => $"{propertyName} == @{index}", 149 | 150 | { Type: FilterModelType.NotEqual, FilterType: FilterModelFilterType.Text } when options.CaseInsensitive => $"{propertyName}.ToLower() != @{index}", 151 | { Type: FilterModelType.NotEqual } => $"{propertyName} != @{index}", 152 | 153 | { Type: FilterModelType.Contains } when options.CaseInsensitive => $"{propertyName}.ToLower().Contains(@{index})", 154 | { Type: FilterModelType.Contains } => $"{propertyName}.Contains(@{index})", 155 | 156 | { Type: FilterModelType.NotContains } when options.CaseInsensitive => $"!{propertyName}.ToLower().Contains(@{index})", 157 | { Type: FilterModelType.NotContains } => $"!{propertyName}.Contains(@{index})", 158 | 159 | { Type: FilterModelType.StartsWith } when options.CaseInsensitive => $"{propertyName}.ToLower().StartsWith(@{index})", 160 | { Type: FilterModelType.StartsWith } => $"{propertyName}.StartsWith(@{index})", 161 | 162 | { Type: FilterModelType.EndsWith } when options.CaseInsensitive => $"{propertyName}.ToLower().EndsWith(@{index})", 163 | { Type: FilterModelType.EndsWith } => $"{propertyName}.EndsWith(@{index})", 164 | 165 | { Type: FilterModelType.LessThan } => $"{propertyName} < @{index}", 166 | { Type: FilterModelType.LessThanOrEqual } => $"{propertyName} <= @{index}", 167 | 168 | { Type: FilterModelType.GreaterThan } => $"{propertyName} > @{index}", 169 | { Type: FilterModelType.GreaterThanOrEqual } => $"{propertyName} >= @{index}", 170 | 171 | { Type: FilterModelType.InRange } when options.InRangeExclusive => $"{propertyName} > @{index} AND {propertyName} < @{index + 1}", 172 | 173 | { Type: FilterModelType.InRange } => $"{propertyName} >= @{index} AND {propertyName} <= @{index + 1}", 174 | 175 | { Type: FilterModelType.Null } => $"{propertyName} == null", 176 | { Type: FilterModelType.NotNull } => $"{propertyName} != null", 177 | 178 | { FilterType: FilterModelFilterType.Set } when options.CaseInsensitive => $"@{index}.Contains({propertyName}.ToLower())", 179 | { FilterType: FilterModelFilterType.Set } => $"@{index}.Contains({propertyName})", 180 | 181 | _ => throw new ArgumentException($"Unable to determine predicate for {colId}. Most likely {nameof(FilterModel.Type)} value ({filterModel.Type}) is unsupported. Supported values: {string.Join(", ", FilterModelType.All)}.") 182 | }; 183 | } 184 | 185 | private static IQueryable Sort(this IQueryable queryable, GetRowsParams getRowsParams) 186 | { 187 | ValidateSortDirections(getRowsParams); 188 | 189 | var orderingParts = getRowsParams.SortModel.Select(s => $"{s.ColId.ToPascalCase()} {s.Sort}"); 190 | 191 | var ordering = string.Join(", ", orderingParts); 192 | 193 | if (ordering.Length == 0) 194 | { 195 | return queryable; 196 | } 197 | 198 | return queryable.OrderBy(ordering); 199 | } 200 | 201 | private static void ValidateSortDirections(GetRowsParams getRowsParams) 202 | { 203 | foreach (var sort in getRowsParams.SortModel) 204 | { 205 | if (!SortModelSortDirection.All.Contains(sort.Sort)) 206 | { 207 | throw new ArgumentException($"Unsupported {nameof(SortModel.Sort)} value ({sort.Sort}). Supported values: {string.Join(", ", SortModelSortDirection.All)}."); 208 | } 209 | } 210 | } 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/QueryableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace AgGrid.InfiniteRowModel 4 | { 5 | public static class QueryableExtensions 6 | { 7 | public static InfiniteRowModelResult GetInfiniteRowModelBlock(this IQueryable queryable, string getRowsParamsJson, InfiniteRowModelOptions options = null) 8 | => GetInfiniteRowModelBlock(queryable, InfiniteScroll.DeserializeGetRowsParams(getRowsParamsJson), options); 9 | 10 | public static InfiniteRowModelResult GetInfiniteRowModelBlock(this IQueryable queryable, GetRowsParams getRowsParams, InfiniteRowModelOptions options = null) 11 | { 12 | var rows = InfiniteScroll.ToQueryableRows(queryable, getRowsParams, options).ToList(); 13 | return InfiniteScroll.ToRowModelResult(getRowsParams, rows); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/AgGrid.InfiniteRowModel/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace AgGrid.InfiniteRowModel 4 | { 5 | internal static class StringExtensions 6 | { 7 | public static string ToPascalCase(this string name) 8 | => Regex.Replace(name, "^([a-z])", m => m.Groups[1].Value.ToUpper()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/AgGrid.InfiniteRowModel.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | e9c91504-f717-45cc-8b73-d907d66153bf 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | all 25 | 26 | 27 | runtime; build; native; contentfiles; analyzers; buildtransitive 28 | all 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Async.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.EntityFrameworkCore; 2 | using AgGrid.InfiniteRowModel.Sample.Database; 3 | using AgGrid.InfiniteRowModel.Sample.Entities; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text.Json; 8 | using System.Threading.Tasks; 9 | using Xunit; 10 | 11 | namespace AgGrid.InfiniteRowModel.Tests 12 | { 13 | public class Async : IDisposable 14 | { 15 | private readonly AppDbContext _dbContext = InMemory.GetDbContext(); 16 | 17 | [Fact] 18 | public async Task Filter() 19 | { 20 | var users = new[] 21 | { 22 | new User { Id = 1, FullName = "Ala Kowalska" }, 23 | new User { Id = 2, FullName = "Jan Kowalski" }, 24 | new User { Id = 3, FullName = "Ala Nowak" } 25 | }; 26 | 27 | _dbContext.Users.AddRange(users); 28 | _dbContext.SaveChanges(); 29 | 30 | var query = new GetRowsParams 31 | { 32 | StartRow = 0, 33 | EndRow = 10, 34 | FilterModel = new Dictionary 35 | { 36 | { "fullName", new FilterModel { Filter = "Kowal", Type = FilterModelType.Contains, FilterType = FilterModelFilterType.Text } } 37 | } 38 | }; 39 | 40 | var result = await _dbContext.Users.GetInfiniteRowModelBlockAsync(query); 41 | 42 | Assert.Contains(result.RowsThisBlock, r => r.Id == 1); 43 | Assert.Contains(result.RowsThisBlock, r => r.Id == 2); 44 | Assert.DoesNotContain(result.RowsThisBlock, r => r.Id == 3); 45 | } 46 | 47 | [Fact] 48 | public async Task ParseFromJson() 49 | { 50 | var users = new[] 51 | { 52 | new User { Id = 1, FullName = "Ala Nowak", Age = 28, IsVerified = true, RegisteredOn = new DateTime(2020, 5, 11) }, 53 | new User { Id = 2, FullName = "Ada Kowalska", Age = 22, IsVerified = false, RegisteredOn = new DateTime(2019, 5, 11) }, 54 | new User { Id = 3, FullName = "Jan Kowalczyk", Age = 33, IsVerified = false, RegisteredOn = new DateTime(2018, 5, 11) }, 55 | new User { Id = 4, FullName = "Andrzej Nowak", Age = 15, IsVerified = true, RegisteredOn = new DateTime(2017, 5, 11) }, 56 | new User { Id = 5, FullName = "Jan Nowak", Age = 34, IsVerified = true, RegisteredOn = new DateTime(2015, 5, 11) } 57 | }; 58 | 59 | _dbContext.Users.AddRange(users); 60 | _dbContext.SaveChanges(); 61 | 62 | var query = new GetRowsParams 63 | { 64 | StartRow = 0, 65 | EndRow = 3, 66 | SortModel = new[] { new SortModel { ColId = "fullName", Sort = SortModelSortDirection.Ascending } }, 67 | FilterModel = new Dictionary 68 | { 69 | { "fullName", new FilterModel { Filter = "Ala", Type = FilterModelType.Contains, FilterType = FilterModelFilterType.Text } }, 70 | { "age", new FilterModel { Filter = 28, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Number } }, 71 | { "isVerified", new FilterModel { Filter = true, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Boolean } }, 72 | { "registeredOn", new FilterModel { DateFrom = "2020-05-08 00:00:00", Type = FilterModelType.GreaterThan, FilterType = FilterModelFilterType.Date } }, 73 | } 74 | }; 75 | 76 | var queryJson = JsonSerializer.Serialize(query, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 77 | 78 | var result = await _dbContext.Users.GetInfiniteRowModelBlockAsync(queryJson); 79 | 80 | Assert.Equal(1, result.RowsThisBlock.Single().Id); 81 | } 82 | 83 | public virtual void Dispose() => _dbContext.Dispose(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Filtering.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using AgGrid.InfiniteRowModel.Sample.Entities; 3 | using AgGrid.InfiniteRowModel.Tests.Models; 4 | using AutoMapper; 5 | using Microsoft.EntityFrameworkCore; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Xunit; 10 | 11 | namespace AgGrid.InfiniteRowModel.Tests 12 | { 13 | public abstract class Filtering : IDisposable 14 | { 15 | protected readonly AppDbContext _dbContext; 16 | 17 | protected Filtering(AppDbContext dbContext) 18 | { 19 | _dbContext = dbContext; 20 | } 21 | 22 | [Theory] 23 | [InlineData("Kowal", FilterModelType.Contains, 1, 2)] 24 | [InlineData("Kowal", FilterModelType.NotContains, 3)] 25 | [InlineData("Ala Kowalska", FilterModelType.Equals, 1)] 26 | [InlineData("Ala Kowalska", FilterModelType.NotEqual, 2, 3, 4)] 27 | [InlineData("Ala", FilterModelType.StartsWith, 1, 3)] 28 | [InlineData("ska", FilterModelType.EndsWith, 1)] 29 | public void FilterByText(string filter, string type, params int[] expectedIds) 30 | { 31 | var users = new[] 32 | { 33 | new User { Id = 1, FullName = "Ala Kowalska" }, 34 | new User { Id = 2, FullName = "Jan Kowalski" }, 35 | new User { Id = 3, FullName = "Ala Nowak" }, 36 | new User { Id = 4, FullName = null } 37 | }; 38 | 39 | _dbContext.Users.AddRange(users); 40 | _dbContext.SaveChanges(); 41 | 42 | var query = new GetRowsParams 43 | { 44 | StartRow = 0, 45 | EndRow = 10, 46 | FilterModel = new Dictionary 47 | { 48 | { "fullName", new FilterModel { Filter = filter, Type = type, FilterType = FilterModelFilterType.Text } } 49 | } 50 | }; 51 | 52 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 53 | 54 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 55 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 56 | } 57 | 58 | [Theory] 59 | [InlineData(true)] 60 | [InlineData(false)] 61 | public void FilterBySet(bool caseInsensitive) 62 | { 63 | var users = new[] 64 | { 65 | new User { Id = 1, FullName = "Ala Kowalska" }, 66 | new User { Id = 2, FullName = "Jan Kowalski" }, 67 | new User { Id = 3, FullName = "Ala Nowak" }, 68 | new User { Id = 4, FullName = null }, 69 | new User { Id = 5, FullName = "Ala Nowak" }, 70 | }; 71 | 72 | _dbContext.Users.AddRange(users); 73 | _dbContext.SaveChanges(); 74 | 75 | var query = new GetRowsParams 76 | { 77 | StartRow = 0, 78 | EndRow = 10, 79 | FilterModel = new Dictionary 80 | { 81 | { "fullName", new FilterModel { Values = new[] { "Jan Kowalski", "Ala Nowak", null }, FilterType = FilterModelFilterType.Set } } 82 | } 83 | }; 84 | 85 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query, new() { CaseInsensitive = caseInsensitive }); 86 | 87 | Assert.Equal(4, result.RowsThisBlock.Count()); 88 | Assert.Contains(result.RowsThisBlock, r => r.Id == 2); 89 | Assert.Contains(result.RowsThisBlock, r => r.Id == 3); 90 | Assert.Contains(result.RowsThisBlock, r => r.Id == 4); 91 | Assert.Contains(result.RowsThisBlock, r => r.Id == 5); 92 | } 93 | 94 | [Theory] 95 | [InlineData(18, FilterModelType.Equals, 3)] 96 | [InlineData(18, FilterModelType.NotEqual, 1, 2)] 97 | [InlineData(22, FilterModelType.LessThan, 3)] 98 | [InlineData(22, FilterModelType.LessThanOrEqual, 1, 3)] 99 | [InlineData(22, FilterModelType.GreaterThan, 2)] 100 | [InlineData(22, FilterModelType.GreaterThanOrEqual, 1, 2)] 101 | [InlineData(22.5, FilterModelType.LessThan, 3, 1)] 102 | public void FilterByNumber(object filter, string type, params int[] expectedIds) 103 | { 104 | var users = new[] 105 | { 106 | new User { Id = 1, Age = 22 }, 107 | new User { Id = 2, Age = 55 }, 108 | new User { Id = 3, Age = 18 } 109 | }; 110 | 111 | _dbContext.Users.AddRange(users); 112 | _dbContext.SaveChanges(); 113 | 114 | var query = new GetRowsParams 115 | { 116 | StartRow = 0, 117 | EndRow = 10, 118 | FilterModel = new Dictionary 119 | { 120 | { "age", new FilterModel { Filter = filter, Type = type, FilterType = FilterModelFilterType.Number } } 121 | } 122 | }; 123 | 124 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 125 | 126 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 127 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 128 | } 129 | 130 | [Fact] 131 | public void FilterByNumberRange() 132 | { 133 | var users = new[] 134 | { 135 | new User { Id = 1, Age = 22 }, 136 | new User { Id = 2, Age = 55 }, 137 | new User { Id = 3, Age = 18 } 138 | }; 139 | 140 | _dbContext.Users.AddRange(users); 141 | _dbContext.SaveChanges(); 142 | 143 | var query = new GetRowsParams 144 | { 145 | StartRow = 0, 146 | EndRow = 10, 147 | FilterModel = new Dictionary 148 | { 149 | { "age", new FilterModel { Filter = 16, FilterTo = 22, Type = FilterModelType.InRange, FilterType = FilterModelFilterType.Number } } 150 | } 151 | }; 152 | 153 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 154 | 155 | Assert.Contains(result.RowsThisBlock, u => u.Id == 1); 156 | Assert.Contains(result.RowsThisBlock, u => u.Id == 3); 157 | Assert.DoesNotContain(result.RowsThisBlock, u => u.Id == 2); 158 | } 159 | 160 | [Theory] 161 | [InlineData(true, FilterModelType.Equals, 1, 2)] 162 | [InlineData(false, FilterModelType.Equals, 3)] 163 | [InlineData(true, FilterModelType.NotEqual, 3)] 164 | [InlineData(false, FilterModelType.NotEqual, 1, 2)] 165 | public void FilterByBoolean(bool filter, string type, params int[] expectedIds) 166 | { 167 | var users = new[] 168 | { 169 | new User { Id = 1, IsVerified = true }, 170 | new User { Id = 2, IsVerified = true}, 171 | new User { Id = 3, IsVerified = false } 172 | }; 173 | 174 | _dbContext.Users.AddRange(users); 175 | _dbContext.SaveChanges(); 176 | 177 | var query = new GetRowsParams 178 | { 179 | StartRow = 0, 180 | EndRow = 10, 181 | FilterModel = new Dictionary 182 | { 183 | { "isVerified", new FilterModel { Filter = filter, Type = type, FilterType = FilterModelFilterType.Boolean } } 184 | } 185 | }; 186 | 187 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 188 | 189 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 190 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 191 | } 192 | 193 | 194 | [Theory] 195 | [InlineData("2020-05-11 00:00:00", FilterModelType.Equals, 1)] 196 | [InlineData("2020-05-11 00:00:00", FilterModelType.NotEqual, 2, 3)] 197 | [InlineData("2019-07-04 00:00:00", FilterModelType.LessThan, 3)] 198 | [InlineData("2019-07-04 00:00:00", FilterModelType.LessThanOrEqual, 2, 3)] 199 | [InlineData("2019-07-04 00:00:00", FilterModelType.GreaterThan, 1)] 200 | [InlineData("2019-07-04 00:00:00", FilterModelType.GreaterThanOrEqual, 1, 2)] 201 | public void FilterByDate(string filter, string type, params int[] expectedIds) 202 | { 203 | var users = new[] 204 | { 205 | new User { Id = 1, RegisteredOn = new DateTime(2020, 5, 11) }, 206 | new User { Id = 2, RegisteredOn = new DateTime(2019, 7, 4) }, 207 | new User { Id = 3, RegisteredOn = new DateTime(2010, 5, 13) } 208 | }; 209 | 210 | _dbContext.Users.AddRange(users); 211 | _dbContext.SaveChanges(); 212 | 213 | var query = new GetRowsParams 214 | { 215 | StartRow = 0, 216 | EndRow = 10, 217 | FilterModel = new Dictionary 218 | { 219 | { "registeredOn", new FilterModel { DateFrom = filter, Type = type, FilterType = FilterModelFilterType.Date } } 220 | } 221 | }; 222 | 223 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 224 | 225 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 226 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 227 | } 228 | 229 | [Fact] 230 | public void FilterByDateRange() 231 | { 232 | var users = new[] 233 | { 234 | new User { Id = 1, RegisteredOn = new DateTime(2020, 5, 11) }, 235 | new User { Id = 2, RegisteredOn = new DateTime(2019, 7, 4) }, 236 | new User { Id = 3, RegisteredOn = new DateTime(2010, 5, 13) } 237 | }; 238 | 239 | _dbContext.Users.AddRange(users); 240 | _dbContext.SaveChanges(); 241 | 242 | var query = new GetRowsParams 243 | { 244 | StartRow = 0, 245 | EndRow = 10, 246 | FilterModel = new Dictionary 247 | { 248 | { 249 | "registeredOn", 250 | new FilterModel 251 | { 252 | DateFrom = "2018-07-04 00:00:00", 253 | DateTo = "2023-07-04 00:00:00", 254 | Type = FilterModelType.InRange, 255 | FilterType = FilterModelFilterType.Date 256 | } 257 | } 258 | } 259 | }; 260 | 261 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 262 | 263 | Assert.Contains(result.RowsThisBlock, u => u.Id == 1); 264 | Assert.Contains(result.RowsThisBlock, u => u.Id == 2); 265 | Assert.DoesNotContain(result.RowsThisBlock, u => u.Id == 3); 266 | } 267 | 268 | [Theory] 269 | [InlineData("Ada", 22, 1)] 270 | [InlineData("Nowak", 18, 3)] 271 | public void FilterByMultipleProperties(string nameFilter, int ageFilter, params int[] expectedIds) 272 | { 273 | var users = new[] 274 | { 275 | new User { Id = 1, FullName = "Ada Kowalska", Age = 22 }, 276 | new User { Id = 2, FullName = "Janek Nowak", Age = 55 }, 277 | new User { Id = 3, FullName = "Ada Nowak", Age = 18 } 278 | }; 279 | 280 | _dbContext.Users.AddRange(users); 281 | _dbContext.SaveChanges(); 282 | 283 | var query = new GetRowsParams 284 | { 285 | StartRow = 0, 286 | EndRow = 10, 287 | FilterModel = new Dictionary 288 | { 289 | { "fullName", new FilterModel { Filter = nameFilter, Type = FilterModelType.Contains, FilterType = FilterModelFilterType.Text } }, 290 | { "age", new FilterModel { Filter = ageFilter, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Number } } 291 | } 292 | }; 293 | 294 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 295 | 296 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 297 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 298 | } 299 | 300 | [Theory] 301 | [InlineData("Ada", "Kowalska", FilterModelOperator.And, 1)] 302 | [InlineData("Nowak", "Kowalczyk", FilterModelOperator.Or, 2, 3)] 303 | public void FilterByMultipleConditions(string filter1, string filter2, string filterOperator, params int[] expectedIds) 304 | { 305 | var users = new[] 306 | { 307 | new User { Id = 1, FullName = "Ada Kowalska" }, 308 | new User { Id = 2, FullName = "Janek Nowak" }, 309 | new User { Id = 3, FullName = "Ada Kowalczyk" } 310 | }; 311 | 312 | _dbContext.Users.AddRange(users); 313 | _dbContext.SaveChanges(); 314 | 315 | var query = new GetRowsParams 316 | { 317 | StartRow = 0, 318 | EndRow = 10, 319 | FilterModel = new Dictionary 320 | { 321 | { 322 | "fullName", 323 | new FilterModel 324 | { 325 | FilterType = FilterModelFilterType.Text, 326 | Operator = filterOperator, 327 | Condition1 = new FilterModel 328 | { 329 | FilterType = FilterModelFilterType.Text, 330 | Type = FilterModelType.Contains, 331 | Filter = filter1 332 | }, 333 | Condition2 = new FilterModel 334 | { 335 | FilterType = FilterModelFilterType.Text, 336 | Type = FilterModelType.Contains, 337 | Filter = filter2 338 | } 339 | } 340 | }, 341 | } 342 | }; 343 | 344 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 345 | 346 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 347 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 348 | } 349 | 350 | [Fact] 351 | public void FilterByNull() 352 | { 353 | var users = new[] 354 | { 355 | new User { Id = 1, FullName = "Ala Kowalska" }, 356 | new User { Id = 2, FullName = null }, 357 | new User { Id = 3, FullName = null }, 358 | new User { Id = 4, FullName = "Jan Kowalski" }, 359 | }; 360 | 361 | _dbContext.Users.AddRange(users); 362 | _dbContext.SaveChanges(); 363 | 364 | var query = new GetRowsParams 365 | { 366 | StartRow = 0, 367 | EndRow = 10, 368 | FilterModel = new Dictionary 369 | { 370 | { "fullName", new FilterModel { Type = FilterModelType.Null, FilterType = FilterModelFilterType.Text } } 371 | } 372 | }; 373 | 374 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 375 | 376 | Assert.Contains(result.RowsThisBlock, r => r.Id == 2); 377 | Assert.Contains(result.RowsThisBlock, r => r.Id == 3); 378 | Assert.DoesNotContain(result.RowsThisBlock, r => r.Id == 4 || r.Id == 1); 379 | } 380 | 381 | [Theory] 382 | [InlineData(FilterModelOperator.And)] 383 | [InlineData(FilterModelOperator.Or, 1, 2, 3)] 384 | public void CombineFilteringByNull(string filterOperator, params int[] expectedIds) 385 | { 386 | var users = new[] 387 | { 388 | new User { Id = 1, FullName = "Ada Kowalska" }, 389 | new User { Id = 2, FullName = null }, 390 | new User { Id = 3, FullName = "Ada Kowalczyk" }, 391 | new User { Id = 4, FullName = "Jan Kowalski" } 392 | }; 393 | 394 | _dbContext.Users.AddRange(users); 395 | _dbContext.SaveChanges(); 396 | 397 | var query = new GetRowsParams 398 | { 399 | StartRow = 0, 400 | EndRow = 10, 401 | FilterModel = new Dictionary 402 | { 403 | { 404 | "fullName", 405 | new FilterModel 406 | { 407 | FilterType = FilterModelFilterType.Text, 408 | Operator = filterOperator, 409 | Condition1 = new FilterModel 410 | { 411 | FilterType = FilterModelFilterType.Text, 412 | Type = FilterModelType.Null 413 | }, 414 | Condition2 = new FilterModel 415 | { 416 | FilterType = FilterModelFilterType.Text, 417 | Type = FilterModelType.StartsWith, 418 | Filter = "A" 419 | } 420 | } 421 | }, 422 | } 423 | }; 424 | 425 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 426 | 427 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 428 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 429 | } 430 | 431 | [Theory] 432 | [InlineData(FilterModelOperator.And, 2)] 433 | [InlineData(FilterModelOperator.Or, 1, 2, 3)] 434 | public void CombineFilteringByRange(string filterOperator, params int[] expectedIds) 435 | { 436 | var users = new[] 437 | { 438 | new User { Id = 1, Age = 32 }, 439 | new User { Id = 2, Age = 55 }, 440 | new User { Id = 3, Age = 66 }, 441 | new User { Id = 4, Age = 77 } 442 | }; 443 | 444 | _dbContext.Users.AddRange(users); 445 | _dbContext.SaveChanges(); 446 | 447 | var query = new GetRowsParams 448 | { 449 | StartRow = 0, 450 | EndRow = 10, 451 | FilterModel = new Dictionary 452 | { 453 | { 454 | "age", 455 | new FilterModel 456 | { 457 | FilterType = FilterModelFilterType.Number, 458 | Operator = filterOperator, 459 | Condition1 = new FilterModel 460 | { 461 | FilterType = FilterModelFilterType.Number, 462 | Type = FilterModelType.InRange, 463 | Filter = 50, 464 | FilterTo = 70 465 | }, 466 | Condition2 = new FilterModel 467 | { 468 | FilterType = FilterModelFilterType.Number, 469 | Type = FilterModelType.LessThan, 470 | Filter = 60 471 | } 472 | } 473 | }, 474 | } 475 | }; 476 | 477 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 478 | 479 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 480 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 481 | } 482 | 483 | [Fact] 484 | public void FilterByNotNull() 485 | { 486 | var users = new[] 487 | { 488 | new User { Id = 1, FullName = "Ala Kowalska" }, 489 | new User { Id = 2, FullName = null }, 490 | new User { Id = 3, FullName = null }, 491 | new User { Id = 4, FullName = "Jan Kowalski" }, 492 | }; 493 | 494 | _dbContext.Users.AddRange(users); 495 | _dbContext.SaveChanges(); 496 | 497 | var query = new GetRowsParams 498 | { 499 | StartRow = 0, 500 | EndRow = 10, 501 | FilterModel = new Dictionary 502 | { 503 | { "fullName", new FilterModel { Type = FilterModelType.NotNull, FilterType = FilterModelFilterType.Text } } 504 | } 505 | }; 506 | 507 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 508 | 509 | Assert.Contains(result.RowsThisBlock, r => r.Id == 1); 510 | Assert.Contains(result.RowsThisBlock, r => r.Id == 4); 511 | Assert.DoesNotContain(result.RowsThisBlock, r => r.Id == 2 || r.Id == 3); 512 | } 513 | 514 | [Theory] 515 | [InlineData("kOwAl", FilterModelType.Contains, 1, 2)] 516 | [InlineData("kOwAl", FilterModelType.NotContains, 3)] 517 | [InlineData("aLa", FilterModelType.StartsWith, 1, 3)] 518 | [InlineData("owaLSKA", FilterModelType.EndsWith, 1)] 519 | [InlineData("ala KOWALSKA", FilterModelType.Equals, 1)] 520 | [InlineData("ala KOWALSKA", FilterModelType.NotEqual, 2, 3)] 521 | public void BeCaseInsensitiveWhenFilteringByTextIfConfiguredToBe(string filter, string type, params int[] expectedIds) 522 | { 523 | var users = new[] 524 | { 525 | new User { Id = 1, FullName = "Ala Kowalska" }, 526 | new User { Id = 2, FullName = "Jan Kowalski" }, 527 | new User { Id = 3, FullName = "Ala Nowak" } 528 | }; 529 | 530 | _dbContext.Users.AddRange(users); 531 | _dbContext.SaveChanges(); 532 | 533 | var query = new GetRowsParams 534 | { 535 | StartRow = 0, 536 | EndRow = 10, 537 | FilterModel = new Dictionary 538 | { 539 | { "fullName", new FilterModel { Filter = filter, Type = type, FilterType = FilterModelFilterType.Text } } 540 | } 541 | }; 542 | 543 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query, new() { CaseInsensitive = true }); 544 | 545 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 546 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 547 | } 548 | 549 | [Fact] 550 | public void BeCaseInsensitiveWhenFilteringBySetIfConfiguredToBe() 551 | { 552 | var users = new[] 553 | { 554 | new User { Id = 1, FullName = "Ala Kowalska" }, 555 | new User { Id = 2, FullName = "Jan Kowalski" }, 556 | new User { Id = 3, FullName = "Ala Nowak" } 557 | }; 558 | 559 | _dbContext.Users.AddRange(users); 560 | _dbContext.SaveChanges(); 561 | 562 | var query = new GetRowsParams 563 | { 564 | StartRow = 0, 565 | EndRow = 10, 566 | FilterModel = new Dictionary 567 | { 568 | { "fullName", new FilterModel { Values = new[] { "jan KOWALSki" }, FilterType = FilterModelFilterType.Set } } 569 | } 570 | }; 571 | 572 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query, new() { CaseInsensitive = true }); 573 | 574 | Assert.Equal(2, result.RowsThisBlock.Single().Id); 575 | } 576 | 577 | [Theory] 578 | [InlineData(22, 34, 2)] 579 | [InlineData(21, 33, 1)] 580 | [InlineData(22, 55, 2, 3)] 581 | public void HaveExclusiveInRangeNumberFilteringIfConfiguredToThisWay(int from, int to, params int[] expectedIds) 582 | { 583 | var users = new[] 584 | { 585 | new User { Id = 1, Age = 22 }, 586 | new User { Id = 2, Age = 33 }, 587 | new User { Id = 3, Age = 44 }, 588 | new User { Id = 4, Age = 55 }, 589 | }; 590 | 591 | _dbContext.Users.AddRange(users); 592 | _dbContext.SaveChanges(); 593 | 594 | var query = new GetRowsParams 595 | { 596 | StartRow = 0, 597 | EndRow = 10, 598 | FilterModel = new Dictionary 599 | { 600 | { "age", new FilterModel { Filter = from, FilterTo = to, Type = FilterModelType.InRange, FilterType = FilterModelFilterType.Number } } 601 | } 602 | }; 603 | 604 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query, new() { InRangeExclusive = true }); 605 | 606 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 607 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 608 | } 609 | 610 | [Fact] 611 | public void HaveInclusiveInRangeNumberFilteringByDefault() 612 | { 613 | var users = new[] 614 | { 615 | new User { Id = 1, Age = 22 }, 616 | new User { Id = 2, Age = 33 }, 617 | new User { Id = 3, Age = 44 }, 618 | new User { Id = 4, Age = 55 }, 619 | }; 620 | 621 | _dbContext.Users.AddRange(users); 622 | _dbContext.SaveChanges(); 623 | 624 | var query = new GetRowsParams 625 | { 626 | StartRow = 0, 627 | EndRow = 10, 628 | FilterModel = new Dictionary 629 | { 630 | { "age", new FilterModel { Filter = 22, FilterTo = 44, Type = FilterModelType.InRange, FilterType = FilterModelFilterType.Number } } 631 | } 632 | }; 633 | 634 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 635 | 636 | Assert.Equal(3, result.RowsThisBlock.Count()); 637 | Assert.Collection(result.RowsThisBlock, r => Assert.Equal(1, r.Id), r => Assert.Equal(2, r.Id), r => Assert.Equal(3, r.Id)); 638 | } 639 | 640 | [Theory] 641 | [InlineData("2019-10-10 00:00:00", "2020-01-01 00:00:00", 2)] 642 | [InlineData("2018-01-01 00:00:00", "2021-11-15 00:00:00", 1, 2)] 643 | [InlineData("2019-10-10 00:00:00", "2021-11-15 04:11:44", 2, 3)] 644 | public void HaveExclusiveInRangeDateFilteringIfConfiguredToThisWay(string from, string to, params int[] expectedIds) 645 | { 646 | var users = new[] 647 | { 648 | new User { Id = 1, RegisteredOn = new DateTime(2019, 10, 10, 0, 0, 0) }, 649 | new User { Id = 2, RegisteredOn = new DateTime(2019, 10, 10, 9, 22, 33) }, 650 | new User { Id = 3, RegisteredOn = new DateTime(2021, 11, 15, 0, 0, 0) }, 651 | new User { Id = 4, RegisteredOn = new DateTime(2021, 11, 15, 4, 11, 44) }, 652 | }; 653 | 654 | _dbContext.Users.AddRange(users); 655 | _dbContext.SaveChanges(); 656 | 657 | var query = new GetRowsParams 658 | { 659 | StartRow = 0, 660 | EndRow = 10, 661 | FilterModel = new Dictionary 662 | { 663 | { "registeredOn", new FilterModel { DateFrom = from, DateTo = to, Type = FilterModelType.InRange, FilterType = FilterModelFilterType.Date } } 664 | } 665 | }; 666 | 667 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query, new() { InRangeExclusive = true }); 668 | 669 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 670 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 671 | } 672 | 673 | [Fact] 674 | public void HaveInclusiveInRangeDateFilteringByDefault() 675 | { 676 | var users = new[] 677 | { 678 | new User { Id = 1, RegisteredOn = new DateTime(2019, 10, 10, 0, 0, 0) }, 679 | new User { Id = 2, RegisteredOn = new DateTime(2019, 10, 10, 9, 22, 33) }, 680 | new User { Id = 3, RegisteredOn = new DateTime(2021, 11, 15, 0, 0, 0) }, 681 | new User { Id = 4, RegisteredOn = new DateTime(2021, 11, 15, 4, 11, 44) }, 682 | }; 683 | 684 | _dbContext.Users.AddRange(users); 685 | _dbContext.SaveChanges(); 686 | 687 | var query = new GetRowsParams 688 | { 689 | StartRow = 0, 690 | EndRow = 10, 691 | FilterModel = new Dictionary 692 | { 693 | { "registeredOn", new FilterModel { DateFrom = "2018-01-01 00:00:00", DateTo = "2021-11-15 00:00:00", Type = FilterModelType.InRange, FilterType = FilterModelFilterType.Date } } 694 | } 695 | }; 696 | 697 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 698 | 699 | Assert.Equal(3, result.RowsThisBlock.Count()); 700 | Assert.Collection(result.RowsThisBlock, r => Assert.Equal(1, r.Id), r => Assert.Equal(2, r.Id), r => Assert.Equal(3, r.Id)); 701 | } 702 | 703 | [Fact] 704 | public void FilterOverProjection() 705 | { 706 | var users = new[] 707 | { 708 | new User { Id = 1, FullName = "Ala Kowalska", Age = 15 }, 709 | new User { Id = 2, FullName = "Jan Kowalski", Age = 20 }, 710 | new User { Id = 3, FullName = "Ala Nowak", Age = 30 } 711 | }; 712 | 713 | _dbContext.Users.AddRange(users); 714 | _dbContext.SaveChanges(); 715 | 716 | var mapperConfiguration = new MapperConfiguration(cfg => 717 | { 718 | const int currentYear = 2020; 719 | 720 | cfg.CreateMap() 721 | .ForMember(d => d.Name, o => o.MapFrom(s => s.FullName)) 722 | .ForMember(d => d.BirthYear, o => o.MapFrom(s => currentYear - s.Age)); 723 | }); 724 | 725 | mapperConfiguration.AssertConfigurationIsValid(); 726 | 727 | var mapper = mapperConfiguration.CreateMapper(); 728 | 729 | var query = new GetRowsParams 730 | { 731 | StartRow = 0, 732 | EndRow = 10, 733 | FilterModel = new Dictionary 734 | { 735 | { "name", new FilterModel { Filter = "Ala", Type = FilterModelType.Contains, FilterType = FilterModelFilterType.Text } }, 736 | { "birthYear", new FilterModel { Filter = 1990, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Number } } 737 | } 738 | }; 739 | 740 | var result = mapper.ProjectTo(_dbContext.Users) 741 | .GetInfiniteRowModelBlock(query); 742 | 743 | Assert.Single(result.RowsThisBlock); 744 | Assert.Equal(3, result.RowsThisBlock.Single().Id); 745 | } 746 | 747 | public virtual void Dispose() => _dbContext.Dispose(); 748 | } 749 | } 750 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/InMemory.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using AgGrid.InfiniteRowModel.Sample.Entities; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using Xunit; 8 | 9 | namespace AgGrid.InfiniteRowModel.Tests 10 | { 11 | public static class InMemory 12 | { 13 | public static AppDbContext GetDbContext() 14 | { 15 | var dbContextOptions = new DbContextOptionsBuilder() 16 | .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) 17 | .Options; 18 | 19 | return new AppDbContext(dbContextOptions); 20 | } 21 | } 22 | 23 | public class InMemoryFiltering : Filtering 24 | { 25 | public InMemoryFiltering() : base(InMemory.GetDbContext()) { } 26 | 27 | [Theory] 28 | [InlineData("Kowalska", FilterModelType.Contains, 1)] 29 | [InlineData("Kowalska", FilterModelType.NotContains, 2)] 30 | [InlineData("Ala", FilterModelType.StartsWith, 1)] 31 | [InlineData("Kowalska", FilterModelType.EndsWith, 1)] 32 | [InlineData("Ala Kowalska", FilterModelType.Equals, 1)] 33 | [InlineData("Ala Kowalska", FilterModelType.NotEqual, 2, 3)] 34 | public void BeCaseSensitiveByDefaultButThisDependsOnDatabaseBehavior(string filter, string type, params int[] expectedIds) 35 | { 36 | var users = new[] 37 | { 38 | new User { Id = 1, FullName = "Ala Kowalska" }, 39 | new User { Id = 2, FullName = "ala kowalska" }, 40 | new User { Id = 3, FullName = null }, 41 | }; 42 | 43 | _dbContext.Users.AddRange(users); 44 | _dbContext.SaveChanges(); 45 | 46 | var query = new GetRowsParams 47 | { 48 | StartRow = 0, 49 | EndRow = 10, 50 | FilterModel = new Dictionary 51 | { 52 | { "fullName", new FilterModel { Filter = filter, Type = type, FilterType = FilterModelFilterType.Text } } 53 | } 54 | }; 55 | 56 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 57 | 58 | Assert.Equal(expectedIds.Length, result.RowsThisBlock.Count()); 59 | Assert.True(result.RowsThisBlock.All(r => expectedIds.Contains(r.Id))); 60 | } 61 | } 62 | 63 | public class InMemoryOrdering : Ordering 64 | { 65 | public InMemoryOrdering() : base(InMemory.GetDbContext()) { } 66 | } 67 | 68 | public class InMemoryPaging : Paging 69 | { 70 | public InMemoryPaging() : base(InMemory.GetDbContext()) { } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Models/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace AgGrid.InfiniteRowModel.Tests.Models 2 | { 3 | public class UserDto 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | public int BirthYear { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/NHibernate.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Entities; 2 | using FluentNHibernate.Cfg; 3 | using FluentNHibernate.Cfg.Db; 4 | using FluentNHibernate.Mapping; 5 | using NHibernate; 6 | using NHibernate.Cfg; 7 | using NHibernate.SqlCommand; 8 | using NHibernate.Tool.hbm2ddl; 9 | using System.Collections.Generic; 10 | using System.IO; 11 | using System.Linq; 12 | using Xunit; 13 | using Xunit.Abstractions; 14 | 15 | namespace AgGrid.InfiniteRowModel.Tests 16 | { 17 | public class NHibernate 18 | { 19 | private const string _dbFile = "nhibernate_test.db"; 20 | 21 | private readonly ITestOutputHelper _output; 22 | 23 | public NHibernate(ITestOutputHelper output) 24 | { 25 | _output = output; 26 | } 27 | 28 | private static ISessionFactory CreateSessionFactory(ITestOutputHelper output) 29 | => Fluently.Configure() 30 | .Database(SQLiteConfiguration.Standard.UsingFile(_dbFile)) 31 | .Mappings(m => m.FluentMappings.Add()) 32 | .ExposeConfiguration(config => 33 | { 34 | BuildSchema(config); 35 | config.SetInterceptor(new NHibernateLoggerInterceptor(output)); 36 | }) 37 | .BuildSessionFactory(); 38 | 39 | private static void BuildSchema(Configuration config) 40 | { 41 | if (File.Exists(_dbFile)) 42 | { 43 | File.Delete(_dbFile); 44 | } 45 | 46 | new SchemaExport(config) 47 | .Create(false, true); 48 | } 49 | 50 | [Fact] 51 | public void BasicFilteringAndSorting() 52 | { 53 | var sessionFactory = CreateSessionFactory(_output); 54 | using var session = sessionFactory.OpenSession(); 55 | 56 | using (var transaction = session.BeginTransaction()) 57 | { 58 | session.Save(new User { Id = 1, FullName = "Jan Kowalski" }); 59 | session.Save(new User { Id = 2, FullName = "Ala Nowak" }); 60 | session.Save(new User { Id = 3, FullName = "Bartosz Kowalski" }); 61 | session.Save(new User { Id = 4, FullName = null }); 62 | 63 | transaction.Commit(); 64 | } 65 | 66 | var query = new GetRowsParams 67 | { 68 | StartRow = 0, 69 | EndRow = 10, 70 | FilterModel = new Dictionary 71 | { 72 | { "fullName", new FilterModel { Filter = "Kowalski", Type = FilterModelType.EndsWith, FilterType = FilterModelFilterType.Text } } 73 | }, 74 | SortModel = new[] 75 | { 76 | new SortModel 77 | { 78 | ColId = "fullName", 79 | Sort = SortModelSortDirection.Ascending 80 | } 81 | } 82 | }; 83 | 84 | var result = session.Query() 85 | .GetInfiniteRowModelBlock(query); 86 | 87 | Assert.Equal(2, result.RowsThisBlock.Count()); 88 | Assert.Equal(3, result.RowsThisBlock.ElementAt(0).Id); 89 | Assert.Equal(1, result.RowsThisBlock.ElementAt(1).Id); 90 | } 91 | } 92 | 93 | public class UserMap : ClassMap 94 | { 95 | public UserMap() 96 | { 97 | Id(u => u.Id); 98 | Map(u => u.FullName); 99 | Map(u => u.RegisteredOn); 100 | Map(u => u.Age); 101 | Map(u => u.IsVerified); 102 | } 103 | } 104 | 105 | public class NHibernateLoggerInterceptor : EmptyInterceptor 106 | { 107 | private readonly ITestOutputHelper _output; 108 | 109 | public NHibernateLoggerInterceptor(ITestOutputHelper output) 110 | { 111 | _output = output; 112 | } 113 | 114 | public override SqlString OnPrepareStatement(SqlString sql) 115 | { 116 | _output.WriteLine(sql.ToString()); 117 | 118 | return base.OnPrepareStatement(sql); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Ordering.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using AgGrid.InfiniteRowModel.Sample.Entities; 3 | using System; 4 | using System.Linq; 5 | using Xunit; 6 | 7 | namespace AgGrid.InfiniteRowModel.Tests 8 | { 9 | public abstract class Ordering : IDisposable 10 | { 11 | protected readonly AppDbContext _dbContext; 12 | 13 | protected Ordering(AppDbContext dbContext) 14 | { 15 | _dbContext = dbContext; 16 | } 17 | 18 | [Fact] 19 | public void OrderByDescending() 20 | { 21 | var users = new[] 22 | { 23 | new User { Id = 1, FullName = "Ala Kowalska" }, 24 | new User { Id = 2, FullName = "Jan Kowalski" }, 25 | new User { Id = 3, FullName = "Ala Nowak" } 26 | }; 27 | 28 | _dbContext.Users.AddRange(users); 29 | _dbContext.SaveChanges(); 30 | 31 | var query = new GetRowsParams 32 | { 33 | StartRow = 0, 34 | EndRow = 10, 35 | SortModel = new[] 36 | { 37 | new SortModel 38 | { 39 | ColId = "fullName", 40 | Sort = SortModelSortDirection.Descending 41 | } 42 | } 43 | }; 44 | 45 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 46 | 47 | Assert.Equal("Jan Kowalski", result.RowsThisBlock.ElementAt(0).FullName); 48 | Assert.Equal("Ala Nowak", result.RowsThisBlock.ElementAt(1).FullName); 49 | Assert.Equal("Ala Kowalska", result.RowsThisBlock.ElementAt(2).FullName); 50 | } 51 | 52 | [Fact] 53 | public void OrderByAscending() 54 | { 55 | var users = new[] 56 | { 57 | new User { Id = 1, FullName = "Ala Nowak" }, 58 | new User { Id = 2, FullName = "Ala Kowalska" }, 59 | new User { Id = 3, FullName = "Jan Kowalski" } 60 | }; 61 | 62 | _dbContext.Users.AddRange(users); 63 | _dbContext.SaveChanges(); 64 | 65 | var query = new GetRowsParams 66 | { 67 | StartRow = 0, 68 | EndRow = 10, 69 | SortModel = new[] 70 | { 71 | new SortModel 72 | { 73 | ColId = "fullName", 74 | Sort = SortModelSortDirection.Ascending 75 | } 76 | } 77 | }; 78 | 79 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 80 | 81 | Assert.Equal("Ala Kowalska", result.RowsThisBlock.ElementAt(0).FullName); 82 | Assert.Equal("Ala Nowak", result.RowsThisBlock.ElementAt(1).FullName); 83 | Assert.Equal("Jan Kowalski", result.RowsThisBlock.ElementAt(2).FullName); 84 | } 85 | 86 | [Fact] 87 | public void OrderByMultipleProperties() 88 | { 89 | var users = new[] 90 | { 91 | new User { Id = 1, FullName = "Jan Kowalski", Age = 18 }, 92 | new User { Id = 2, FullName = "Ala Nowak", Age = 21 }, 93 | new User { Id = 3, FullName = "Ala Nowak", Age = 22 } 94 | }; 95 | 96 | _dbContext.Users.AddRange(users); 97 | _dbContext.SaveChanges(); 98 | 99 | var query = new GetRowsParams 100 | { 101 | StartRow = 0, 102 | EndRow = 10, 103 | SortModel = new[] 104 | { 105 | new SortModel 106 | { 107 | ColId = "fullName", 108 | Sort = SortModelSortDirection.Ascending 109 | }, 110 | new SortModel 111 | { 112 | ColId = "age", 113 | Sort = SortModelSortDirection.Ascending 114 | } 115 | } 116 | }; 117 | 118 | var result = _dbContext.Users.GetInfiniteRowModelBlock(query); 119 | 120 | Assert.Equal(21, result.RowsThisBlock.ElementAt(0).Age); 121 | Assert.Equal(22, result.RowsThisBlock.ElementAt(1).Age); 122 | Assert.Equal(18, result.RowsThisBlock.ElementAt(2).Age); 123 | } 124 | 125 | public virtual void Dispose() => _dbContext.Dispose(); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Paging.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using AgGrid.InfiniteRowModel.Sample.Entities; 3 | using System; 4 | using System.Linq; 5 | using Xunit; 6 | 7 | namespace AgGrid.InfiniteRowModel.Tests 8 | { 9 | public abstract class Paging : IDisposable 10 | { 11 | protected readonly AppDbContext _dbContext; 12 | 13 | protected Paging(AppDbContext dbContext) 14 | { 15 | _dbContext = dbContext; 16 | } 17 | 18 | [Fact] 19 | public void Page() 20 | { 21 | var users = new[] 22 | { 23 | new User { Id = 1, FullName = "1" }, 24 | new User { Id = 2, FullName = "2" }, 25 | new User { Id = 3, FullName = "3" }, 26 | new User { Id = 4, FullName = "4" }, 27 | new User { Id = 5, FullName = "5" } 28 | }; 29 | 30 | _dbContext.Users.AddRange(users); 31 | _dbContext.SaveChanges(); 32 | 33 | var query = new GetRowsParams 34 | { 35 | StartRow = 0, 36 | EndRow = 3, 37 | SortModel = new[] { new SortModel { ColId = "fullName", Sort = SortModelSortDirection.Ascending } } 38 | }; 39 | 40 | var page1 = _dbContext.Users.GetInfiniteRowModelBlock(query); 41 | 42 | Assert.Null(page1.LastRow); 43 | Assert.Equal(3, page1.RowsThisBlock.Count()); 44 | Assert.Contains(page1.RowsThisBlock, u => u.FullName == "1"); 45 | Assert.Contains(page1.RowsThisBlock, u => u.FullName == "2"); 46 | Assert.Contains(page1.RowsThisBlock, u => u.FullName == "3"); 47 | 48 | query.StartRow = 3; 49 | query.EndRow = 6; 50 | 51 | var page2 = _dbContext.Users.GetInfiniteRowModelBlock(query); 52 | 53 | Assert.Equal(5, page2.LastRow); 54 | Assert.Equal(2, page2.RowsThisBlock.Count()); 55 | Assert.Contains(page2.RowsThisBlock, u => u.FullName == "4"); 56 | Assert.Contains(page2.RowsThisBlock, u => u.FullName == "5"); 57 | } 58 | 59 | public virtual void Dispose() => _dbContext.Dispose(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Parsing.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using AgGrid.InfiniteRowModel.Sample.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text.Json; 7 | using Xunit; 8 | 9 | namespace AgGrid.InfiniteRowModel.Tests 10 | { 11 | public class Parsing : IDisposable 12 | { 13 | private readonly AppDbContext _dbContext = InMemory.GetDbContext(); 14 | 15 | [Fact] 16 | public void ParseFromJson() 17 | { 18 | var users = new[] 19 | { 20 | new User { Id = 1, FullName = "Ala Nowak", Age = 28, IsVerified = true, RegisteredOn = new DateTime(2020, 5, 11) }, 21 | new User { Id = 2, FullName = "Ada Kowalska", Age = 22, IsVerified = false, RegisteredOn = new DateTime(2019, 5, 11) }, 22 | new User { Id = 3, FullName = "Jan Kowalczyk", Age = 33, IsVerified = false, RegisteredOn = new DateTime(2018, 5, 11) }, 23 | new User { Id = 4, FullName = "Andrzej Nowak", Age = 15, IsVerified = true, RegisteredOn = new DateTime(2017, 5, 11) }, 24 | new User { Id = 5, FullName = "Jan Nowak", Age = 34, IsVerified = true, RegisteredOn = new DateTime(2015, 5, 11) } 25 | }; 26 | 27 | _dbContext.Users.AddRange(users); 28 | _dbContext.SaveChanges(); 29 | 30 | var query = new GetRowsParams 31 | { 32 | StartRow = 0, 33 | EndRow = 3, 34 | SortModel = new[] { new SortModel { ColId = "fullName", Sort = SortModelSortDirection.Ascending } }, 35 | FilterModel = new Dictionary 36 | { 37 | { "fullName", new FilterModel { Filter = "Ala", Type = FilterModelType.Contains, FilterType = FilterModelFilterType.Text } }, 38 | { "age", new FilterModel { Filter = 28, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Number } }, 39 | { "isVerified", new FilterModel { Filter = true, Type = FilterModelType.Equals, FilterType = FilterModelFilterType.Boolean } }, 40 | { "registeredOn", new FilterModel { DateFrom = "2020-05-08 00:00:00", Type = FilterModelType.GreaterThan, FilterType = FilterModelFilterType.Date } }, 41 | } 42 | }; 43 | 44 | var queryJson = JsonSerializer.Serialize(query, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 45 | 46 | var result = _dbContext.Users.GetInfiniteRowModelBlock(queryJson); 47 | 48 | Assert.Equal(1, result.RowsThisBlock.Single().Id); 49 | } 50 | 51 | public void Dispose() => _dbContext.Dispose(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/PostgreSQL.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Diagnostics; 4 | using Microsoft.Extensions.Configuration; 5 | using System; 6 | using Xunit.Abstractions; 7 | 8 | namespace AgGrid.InfiniteRowModel.Tests 9 | { 10 | public static class PostgreSQL 11 | { 12 | public static AppDbContext GetDbContext(ITestOutputHelper output) 13 | { 14 | var configuration = new ConfigurationBuilder() 15 | .AddUserSecrets(typeof(PostgreSQL).Assembly) 16 | .Build(); 17 | 18 | var dbContextOptions = new DbContextOptionsBuilder() 19 | .UseNpgsql($"Host=localhost;Username={configuration["PostgreSQL:Username"]};Password={configuration["PostgreSQL:Password"]};Database={Guid.NewGuid()}") 20 | .LogTo(output.WriteLine, (eventId, _) => eventId == RelationalEventId.CommandExecuted) 21 | .Options; 22 | 23 | var dbContext = new AppDbContext(dbContextOptions); 24 | 25 | dbContext.Database.EnsureCreated(); 26 | 27 | return dbContext; 28 | } 29 | 30 | public static void Cleanup(AppDbContext dbContext) => dbContext.Database.EnsureDeleted(); 31 | } 32 | 33 | public class PostgreSQLFiltering : Filtering 34 | { 35 | public PostgreSQLFiltering(ITestOutputHelper output) : base(PostgreSQL.GetDbContext(output)) { } 36 | 37 | public override void Dispose() 38 | { 39 | PostgreSQL.Cleanup(_dbContext); 40 | base.Dispose(); 41 | } 42 | } 43 | 44 | public class PostgreSQLOrdering : Ordering 45 | { 46 | public PostgreSQLOrdering(ITestOutputHelper output) : base(PostgreSQL.GetDbContext(output)) { } 47 | 48 | public override void Dispose() 49 | { 50 | PostgreSQL.Cleanup(_dbContext); 51 | base.Dispose(); 52 | } 53 | } 54 | 55 | public class PostgreSQLPaging : Paging 56 | { 57 | public PostgreSQLPaging(ITestOutputHelper output) : base(PostgreSQL.GetDbContext(output)) { } 58 | 59 | public override void Dispose() 60 | { 61 | PostgreSQL.Cleanup(_dbContext); 62 | base.Dispose(); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/SqlServer.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Diagnostics; 4 | using System; 5 | using Xunit.Abstractions; 6 | 7 | namespace AgGrid.InfiniteRowModel.Tests 8 | { 9 | public static class SqlServer 10 | { 11 | public static AppDbContext GetDbContext(ITestOutputHelper output) 12 | { 13 | var dbContextOptions = new DbContextOptionsBuilder() 14 | .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={Guid.NewGuid()};Trusted_Connection=True;") 15 | .LogTo(output.WriteLine, (eventId, _) => eventId == RelationalEventId.CommandExecuted) 16 | .Options; 17 | 18 | var dbContext = new AppDbContext(dbContextOptions); 19 | 20 | dbContext.Database.EnsureCreated(); 21 | 22 | dbContext.Database.OpenConnection(); 23 | dbContext.Database.ExecuteSqlRaw("SET IDENTITY_INSERT Users ON"); 24 | 25 | return dbContext; 26 | } 27 | 28 | public static void Cleanup(AppDbContext dbContext) 29 | { 30 | dbContext.Database.CloseConnection(); 31 | dbContext.Database.EnsureDeleted(); 32 | } 33 | } 34 | 35 | public class SqlServerFiltering : Filtering 36 | { 37 | public SqlServerFiltering(ITestOutputHelper output) : base(SqlServer.GetDbContext(output)) { } 38 | 39 | public override void Dispose() 40 | { 41 | SqlServer.Cleanup(_dbContext); 42 | base.Dispose(); 43 | } 44 | } 45 | 46 | public class SqlServerOrdering : Ordering 47 | { 48 | public SqlServerOrdering(ITestOutputHelper output) : base(SqlServer.GetDbContext(output)) { } 49 | 50 | public override void Dispose() 51 | { 52 | SqlServer.Cleanup(_dbContext); 53 | base.Dispose(); 54 | } 55 | } 56 | 57 | public class SqlServerPaging : Paging 58 | { 59 | public SqlServerPaging(ITestOutputHelper output) : base(SqlServer.GetDbContext(output)) { } 60 | 61 | public override void Dispose() 62 | { 63 | SqlServer.Cleanup(_dbContext); 64 | base.Dispose(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Sqlite.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.Data.Sqlite; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Diagnostics; 5 | using Xunit.Abstractions; 6 | 7 | namespace AgGrid.InfiniteRowModel.Tests 8 | { 9 | public static class Sqlite 10 | { 11 | public static AppDbContext GetDbContext(ITestOutputHelper output) 12 | { 13 | var connection = new SqliteConnection("Filename=:memory:"); 14 | connection.Open(); 15 | 16 | var dbContextOptions = new DbContextOptionsBuilder() 17 | .UseSqlite(connection) 18 | .LogTo(output.WriteLine, (eventId, _) => eventId == RelationalEventId.CommandExecuted) 19 | .Options; 20 | 21 | var dbContext = new AppDbContext(dbContextOptions); 22 | 23 | dbContext.Database.EnsureCreated(); 24 | 25 | return dbContext; 26 | } 27 | 28 | public static void Cleanup(AppDbContext dbContext) => dbContext.Database.GetDbConnection().Close(); 29 | } 30 | 31 | public class SqliteFiltering : Filtering 32 | { 33 | public SqliteFiltering(ITestOutputHelper output) : base(Sqlite.GetDbContext(output)) { } 34 | 35 | public override void Dispose() 36 | { 37 | Sqlite.Cleanup(_dbContext); 38 | base.Dispose(); 39 | } 40 | } 41 | 42 | public class SqliteOrdering : Ordering 43 | { 44 | public SqliteOrdering(ITestOutputHelper output) : base(Sqlite.GetDbContext(output)) { } 45 | 46 | public override void Dispose() 47 | { 48 | Sqlite.Cleanup(_dbContext); 49 | base.Dispose(); 50 | } 51 | } 52 | 53 | public class SqlitePaging : Paging 54 | { 55 | public SqlitePaging(ITestOutputHelper output) : base(Sqlite.GetDbContext(output)) { } 56 | 57 | public override void Dispose() 58 | { 59 | Sqlite.Cleanup(_dbContext); 60 | base.Dispose(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/AgGrid.InfiniteRowModel.Tests/Validation.cs: -------------------------------------------------------------------------------- 1 | using AgGrid.InfiniteRowModel.Sample.Database; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Xunit; 7 | 8 | namespace AgGrid.InfiniteRowModel.Tests 9 | { 10 | public class Validation : IDisposable 11 | { 12 | private readonly AppDbContext _dbContext = InMemory.GetDbContext(); 13 | 14 | [Fact] 15 | public void ValidateColIds() 16 | { 17 | var query = new GetRowsParams 18 | { 19 | StartRow = 0, 20 | EndRow = 10, 21 | FilterModel = new Dictionary 22 | { 23 | { 24 | "invalidColId", 25 | new FilterModel 26 | { 27 | Filter = "test", 28 | Type = FilterModelType.Contains, 29 | FilterType = FilterModelFilterType.Text 30 | } 31 | }, 32 | { 33 | "anotherInvalidColId", 34 | new FilterModel 35 | { 36 | Filter = 5, 37 | Type = FilterModelType.Equals, 38 | FilterType = FilterModelFilterType.Number 39 | } 40 | } 41 | } 42 | }; 43 | 44 | var exception = Assert.Throws(() =>_dbContext.Users.GetInfiniteRowModelBlock(query)); 45 | Assert.Contains("colId", exception.Message); 46 | Assert.Contains(query.FilterModel.First().Key, exception.Message); 47 | Assert.Contains(query.FilterModel.Last().Key, exception.Message); 48 | } 49 | 50 | [Fact] 51 | public void ValidateSortOrder() 52 | { 53 | var query = new GetRowsParams 54 | { 55 | StartRow = 0, 56 | EndRow = 10, 57 | SortModel = new[] 58 | { 59 | new SortModel 60 | { 61 | ColId = "fullName", 62 | Sort = "madeUpSortOrder" 63 | } 64 | } 65 | }; 66 | 67 | var exception = Assert.Throws(() => _dbContext.Users.GetInfiniteRowModelBlock(query)); 68 | Assert.Contains(nameof(SortModel.Sort), exception.Message); 69 | Assert.Contains(query.SortModel.First().Sort, exception.Message); 70 | } 71 | 72 | [Fact] 73 | public void ValidateOperator() 74 | { 75 | var query = new GetRowsParams 76 | { 77 | StartRow = 0, 78 | EndRow = 10, 79 | FilterModel = new Dictionary 80 | { 81 | { 82 | "fullName", 83 | new FilterModel 84 | { 85 | FilterType = FilterModelFilterType.Text, 86 | Operator = "madeUpOperator", 87 | Condition1 = new FilterModel 88 | { 89 | FilterType = FilterModelFilterType.Text, 90 | Type = FilterModelType.Contains, 91 | Filter = "test" 92 | }, 93 | Condition2 = new FilterModel 94 | { 95 | FilterType = FilterModelFilterType.Text, 96 | Type = FilterModelType.Contains, 97 | Filter = "test" 98 | } 99 | } 100 | }, 101 | } 102 | }; 103 | 104 | var exception = Assert.Throws(() => _dbContext.Users.GetInfiniteRowModelBlock(query)); 105 | Assert.Contains(nameof(FilterModel.Operator), exception.Message); 106 | Assert.Contains(query.FilterModel.First().Value.Operator, exception.Message); 107 | } 108 | 109 | public void Dispose() => _dbContext.Dispose(); 110 | } 111 | } 112 | --------------------------------------------------------------------------------