@@ -78,6 +78,8 @@ public async Task TestCursorPagingWithRawSqlWhereClauseAndNullPagingParamValuesA
7878 {
7979 using var sqlConnection = await CreateSqlConnectionAsync ( ) . ConfigureAwait ( false ) ;
8080
81+ var namePattern = "%Luke%" ;
82+
8183 ICursorPageResults < CharacterDbModel > page = await sqlConnection . ExecutePagingCursorQueryAsync < CharacterDbModel > (
8284 //TEST Formatted SQL with line breaks, ending semi-colon, etc....
8385 commandText : @"
@@ -90,16 +92,46 @@ FROM [dbo].[StarWarsCharacters] c
9092 pagingParams : CursorPagingParams . ForCursors ( null , null , null , null ) ,
9193 sqlParams : new
9294 {
93- NamePattern = "%Luke%"
95+ NamePattern = namePattern
9496 }
9597 ) ;
9698
9799 page . Should ( ) . NotBeNull ( ) ;
98100 page . TotalCount . Should ( ) . BeNull ( ) ;
99101 page . CursorResults . Should ( ) . HaveCount ( 1 ) ;
100102
101- TestContext . WriteLine ( "" ) ;
102- TestContext . WriteLine ( $ "[{ page . PageCount } ] Page Results:") ;
103+ TestContext . WriteLine ( "NO Cursor values provided so ALL results are expected..." ) ;
104+ TestContext . WriteLine ( $ "[{ namePattern } ] WHERE Filter Applied to Limit Primary Result Set...") ;
105+ TestContext . WriteLine ( $ "[{ page . PageCount } ] Page Results Returned...") ;
106+ }
107+
108+ [ TestMethod ]
109+ public async Task TestCursorPagingWithRawSqlWhereClauseToGetTotalCountButNoResults ( )
110+ {
111+ using var sqlConnection = await CreateSqlConnectionAsync ( ) . ConfigureAwait ( false ) ;
112+
113+ ICursorPageResults < CharacterDbModel > page = await sqlConnection . ExecutePagingCursorQueryAsync < CharacterDbModel > (
114+ //TEST Formatted SQL with line breaks, ending semi-colon, etc....
115+ commandText : @"
116+ SELECT *
117+ FROM [dbo].[StarWarsCharacters] c
118+ WHERE c.[Name] LIKE @NamePattern;
119+ " ,
120+ new [ ] { OrderField . Descending < CharacterDbModel > ( c => c . Id ) } ,
121+ //TEST PASSING IN Empty Paging Params (all values being NULL)....
122+ pagingParams : CursorPagingParams . ForCursors ( first : 0 , retrieveTotalCount : true ) ,
123+ sqlParams : new
124+ {
125+ NamePattern = "%Luke%"
126+ }
127+ ) ;
128+
129+ page . Should ( ) . NotBeNull ( ) ;
130+ page . TotalCount . Should ( ) . Be ( 1 ) ; //TOTAL Count == 1
131+ page . CursorResults . Should ( ) . HaveCount ( 0 ) ; //NO RESULTS REQUESTED!
132+
133+ TestContext . WriteLine ( $ "[{ page . TotalCount } ] Total Results...") ;
134+ TestContext . WriteLine ( $ "[{ page . PageCount } ] Page Results Returned...") ;
103135 }
104136
105137 [ TestMethod ]
0 commit comments