@@ -19,18 +19,18 @@ public class Person
19
19
{
20
20
[ PrimaryKey ( 1 ) ] public uint TenantId { get ; set ; }
21
21
22
- [ PrimaryKey ( 2 ) ]
23
- public string ? Email { get ; set ; }
22
+ [ PrimaryKey ( 2 ) ] public string ? Email { get ; set ; }
24
23
25
- [ InKeyValue ( 3 ) ]
26
- public DateTime LastLogin { get ; set ; }
24
+ [ InKeyValue ( 3 ) ] public DateTime LastLogin { get ; set ; }
27
25
28
26
public string ? Name { get ; set ; }
29
27
}
30
28
31
29
public interface IPersonTable : IRelation < Person >
32
30
{
33
- IEnumerable < Person > ScanById ( Constraint < ulong > tenantId , Constraint < string > email , Constraint < DateTime > lastLogin ) ;
31
+ IEnumerable < Person > ScanById ( Constraint < ulong > tenantId , Constraint < string > email ,
32
+ Constraint < DateTime > lastLogin ) ;
33
+
34
34
bool UpdateById ( uint tenantId , string email , DateTime lastLogin ) ;
35
35
bool UpdateById ( uint tenantId , string email , DateTime lastLogin , string name ) ;
36
36
void Insert ( Person person ) ;
@@ -87,7 +87,7 @@ public void RemoveByIdWorks()
87
87
using var tr = _db . StartTransaction ( ) ;
88
88
var t = tr . GetRelation < IPersonTable > ( ) ;
89
89
t . RemoveById ( 1 , "[email protected] " ) ;
90
- Assert . Equal ( 3 , t . Count ) ;
90
+ Assert . Equal ( 3 , t . Count ) ;
91
91
}
92
92
93
93
[ Fact ]
@@ -97,7 +97,8 @@ public void FullCaseUpdateByIdWorks()
97
97
98
98
using var tr = _db . StartTransaction ( ) ;
99
99
var t = tr . GetRelation < IPersonTable > ( ) ;
100
- Assert . False ( t . UpdateById ( 1 , "[email protected] " , new DateTime ( 2023 , 7 , 30 , 0 , 0 , 0 , DateTimeKind . Utc ) , "does not matter" ) ) ;
100
+ Assert . False ( t . UpdateById ( 1 , "[email protected] " , new DateTime ( 2023 , 7 , 30 , 0 , 0 , 0 , DateTimeKind . Utc ) ,
101
+ "does not matter" ) ) ;
101
102
Assert . True ( t . UpdateById ( 1 , "[email protected] " , new DateTime ( 2023 , 7 , 30 , 0 , 0 , 0 , DateTimeKind . Utc ) , "OK" ) ) ;
102
103
Assert . Equal ( "A" ,
103
104
string . Join ( "" ,
@@ -116,13 +117,16 @@ public void InsertAndUpdateWorks()
116
117
117
118
using var tr = _db . StartTransaction ( ) ;
118
119
var t = tr . GetRelation < IPersonTable > ( ) ;
119
- t . Insert ( new ( ) { TenantId = 1 , Email = "[email protected] " , Name = "BB" , LastLogin = new ( 2023 , 7 , 30 , 0 , 0 , 0 , DateTimeKind . Utc ) } ) ;
120
+ t . Insert ( new ( )
121
+ { TenantId = 1 , Email = "[email protected] " , Name = "BB" , LastLogin = new ( 2023 , 7 , 30 , 0 , 0 , 0 , DateTimeKind . Utc ) } ) ;
120
122
Assert . Equal ( "BB" ,
121
123
t . ScanById ( Constraint . Unsigned . Exact ( 1 ) , Constraint . String . Exact ( "[email protected] " ) , Constraint < DateTime > . Any )
122
124
. Single ( ) . Name ) ;
123
- t . Update ( new ( ) { TenantId = 1 , Email = "[email protected] " , Name = "CC" , LastLogin = new ( 2024 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) } ) ;
125
+ t . Update ( new ( )
126
+ { TenantId = 1 , Email = "[email protected] " , Name = "CC" , LastLogin = new ( 2024 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) } ) ;
124
127
Assert . Equal ( "CC" ,
125
- t . ScanById ( Constraint . Unsigned . Exact ( 1 ) , Constraint . String . Exact ( "[email protected] " ) , Constraint . DateTime . Predicate ( d
=> d . Year == 2024 ) )
128
+ t . ScanById ( Constraint . Unsigned . Exact ( 1 ) , Constraint . String . Exact ( "[email protected] " ) ,
129
+ Constraint . DateTime . Predicate ( d => d . Year == 2024 ) )
126
130
. Single ( ) . Name ) ;
127
131
}
128
132
@@ -161,8 +165,7 @@ public class DataV2
161
165
162
166
public string Name { get ; set ; }
163
167
164
- [ InKeyValue ( 2 ) ]
165
- public int Age { get ; set ; }
168
+ [ InKeyValue ( 2 ) ] public int Age { get ; set ; }
166
169
}
167
170
168
171
[ PersistedName ( "Data" ) ]
@@ -177,8 +180,8 @@ public void PromotionValueToInKeyValueWorks()
177
180
{
178
181
using var tr = _db . StartTransaction ( ) ;
179
182
var t = tr . GetRelation < IDataV1Table > ( ) ;
180
- t . Upsert ( new ( ) { Id = 1 , Name = "A" , Age = 11 } ) ;
181
- t . Upsert ( new ( ) { Id = 2 , Name = "B" , Age = 22 } ) ;
183
+ t . Upsert ( new ( ) { Id = 1 , Name = "A" , Age = 11 } ) ;
184
+ t . Upsert ( new ( ) { Id = 2 , Name = "B" , Age = 22 } ) ;
182
185
tr . Commit ( ) ;
183
186
}
184
187
ReopenDb ( ) ;
@@ -206,17 +209,16 @@ public void PromotionValueToInKeyValueWorks()
206
209
207
210
public class ListData
208
211
{
209
- [ PrimaryKey ( 1 ) ]
210
- public uint Id { get ; set ; }
211
- [ PrimaryKey ( 2 ) ]
212
- public uint QueueStamp { get ; set ; }
213
- [ PrimaryKey ( 3 , InKeyValue = true ) ]
214
- public bool IsProcessed { get ; set ; }
212
+ [ PrimaryKey ( 1 ) ] public uint Id { get ; set ; }
213
+ [ PrimaryKey ( 2 ) ] public uint QueueStamp { get ; set ; }
214
+ [ PrimaryKey ( 3 , InKeyValue = true ) ] public bool IsProcessed { get ; set ; }
215
+ [ SecondaryKey ( "SomeKey" ) ] public string ? SomeKey { get ; set ; }
215
216
}
216
217
217
218
public interface IListDataTable : IRelation < ListData >
218
219
{
219
220
IEnumerable < ListData > ListById ( uint id , AdvancedEnumeratorParam < uint > queueStampParam ) ;
221
+ int RemoveById ( uint id , AdvancedEnumeratorParam < uint > queueStampParam ) ;
220
222
}
221
223
222
224
[ Fact ]
@@ -226,7 +228,22 @@ public void ListingWithAdvancedEnumeratorParam()
226
228
227
229
using var tr = _db . StartTransaction ( ) ;
228
230
var t = tr . GetRelation < IListDataTable > ( ) ;
229
- Assert . Equal ( 2 , t . ListById ( 1 , new ( EnumerationOrder . Ascending , 2 , KeyProposition . Excluded , uint . MaxValue , KeyProposition . Included ) ) . Count ( ) ) ;
231
+ Assert . Equal ( 2 ,
232
+ t . ListById ( 1 ,
233
+ new ( EnumerationOrder . Ascending , 2 , KeyProposition . Excluded , uint . MaxValue , KeyProposition . Included ) )
234
+ . Count ( ) ) ;
235
+ }
236
+
237
+ [ Fact ]
238
+ public void RemoveByIdWithAdvancedEnumeratorParam ( )
239
+ {
240
+ FillListingData ( ) ;
241
+
242
+ using var tr = _db . StartTransaction ( ) ;
243
+ var t = tr . GetRelation < IListDataTable > ( ) ;
244
+ Assert . Equal ( 2 ,
245
+ t . RemoveById ( 1 , new ( EnumerationOrder . Ascending , 2 , KeyProposition . Included , 3 , KeyProposition . Included ) ) ) ;
246
+ Assert . Equal ( 2 , t . Count ) ;
230
247
}
231
248
232
249
void FillListingData ( )
0 commit comments