@@ -3031,6 +3031,51 @@ public interface ICategoryTable : IRelation<Category>
3031
3031
bool RemoveById ( ulong tenantId , ulong id ) ;
3032
3032
}
3033
3033
3034
+ public class ContentVersion
3035
+ {
3036
+ [ PrimaryKey ( 1 ) ] public ulong CompanyId { get ; set ; }
3037
+
3038
+ [ PrimaryKey ( 2 ) ] public ulong ContentId { get ; set ; }
3039
+
3040
+ [ PrimaryKey ( 3 ) ]
3041
+ [ SecondaryKey ( "State" , Order = 4 ) ]
3042
+ public uint Version { get ; set ; }
3043
+
3044
+ [ SecondaryKey ( "State" , Order = 3 , IncludePrimaryKeyOrder = 2 ) ]
3045
+ public ContentVersionState State { get ; set ; }
3046
+ }
3047
+
3048
+ public enum ContentVersionState
3049
+ {
3050
+ Published = 0 ,
3051
+ PreviouslyPublished = 1 ,
3052
+ }
3053
+
3054
+ public interface IContentVersionTable : IRelation < ContentVersion >
3055
+ {
3056
+ IEnumerable < ContentVersion > ListByState ( ulong companyId , ulong contentId , ContentVersionState state , AdvancedEnumeratorParam < uint > param ) ;
3057
+ }
3058
+
3059
+ [ Fact ]
3060
+ void CanUpdateWhileEnumeratingUsingListBySecondaryKey ( )
3061
+ {
3062
+ using var tr = _db . StartTransaction ( ) ;
3063
+ var table = tr . GetRelation < IContentVersionTable > ( ) ;
3064
+ table . Upsert ( new ContentVersion ( ) { CompanyId = 1 , ContentId = 2 , State = ContentVersionState . Published , Version = 501 } ) ;
3065
+ table . Upsert ( new ContentVersion ( ) { CompanyId = 1 , ContentId = 2 , State = ContentVersionState . Published , Version = 502 } ) ;
3066
+ int count = 0 ;
3067
+ var enumerator = table . ListByState ( 1 , 2 , ContentVersionState . Published , new AdvancedEnumeratorParam < uint > ( EnumerationOrder . Descending ) ) ;
3068
+ foreach ( var contentVersion in enumerator )
3069
+ {
3070
+ count ++ ;
3071
+ contentVersion . State = ContentVersionState . PreviouslyPublished ;
3072
+ table . Upsert ( contentVersion ) ;
3073
+ }
3074
+
3075
+ Assert . Equal ( 2 , count ) ;
3076
+
3077
+ }
3078
+
3034
3079
[ Fact ]
3035
3080
void SecondaryIndexWithLowercasedStringWorks ( )
3036
3081
{
0 commit comments