@@ -417,17 +417,14 @@ private void PerformGetReferencedDtos(List<UserDto> dtos)
417417 Sql < ISqlContext > sql ;
418418 try
419419 {
420- sql = SqlContext . Sql ( )
421- . Select < UserGroupDto > ( x => x . Id , x => x . Key )
422- . From < UserGroupDto > ( )
423- . InnerJoin < User2UserGroupDto > ( ) . On < UserGroupDto , User2UserGroupDto > ( ( left , right ) => left . Id == right . UserGroupId )
424- . WhereIn < User2UserGroupDto > ( x => x . UserId , userIds ) ;
425-
426- List < UserGroupDto > ? userGroups = Database . Fetch < UserGroupDto > ( sql ) ;
427-
428-
429- groupKeys = userGroups . Select ( x => x . Key ) . ToList ( ) ;
430-
420+ groupKeys = Database . FetchByGroups < UserGroupDto , int > ( userIds , Constants . Sql . MaxParameterCount , ints =>
421+ {
422+ return SqlContext . Sql ( )
423+ . Select < UserGroupDto > ( x => x . Id , x => x . Key )
424+ . From < UserGroupDto > ( )
425+ . InnerJoin < User2UserGroupDto > ( ) . On < UserGroupDto , User2UserGroupDto > ( ( left , right ) => left . Id == right . UserGroupId )
426+ . WhereIn < User2UserGroupDto > ( x => x . UserId , ints ) ;
427+ } ) . Select ( x => x . Key ) . ToList ( ) ;
431428 }
432429 catch ( DbException )
433430 {
@@ -441,20 +438,20 @@ private void PerformGetReferencedDtos(List<UserDto> dtos)
441438
442439
443440 // get users2groups
444- sql = SqlContext . Sql ( )
445- . Select < User2UserGroupDto > ( )
446- . From < User2UserGroupDto > ( )
447- . WhereIn < User2UserGroupDto > ( x => x . UserId , userIds ) ;
448-
449- List < User2UserGroupDto > ? user2Groups = Database . Fetch < User2UserGroupDto > ( sql ) ;
441+ List < User2UserGroupDto > ? user2Groups = Database . FetchByGroups < User2UserGroupDto , int > ( userIds , Constants . Sql . MaxParameterCount , ints =>
442+ {
443+ return SqlContext . Sql ( )
444+ . Select < User2UserGroupDto > ( )
445+ . From < User2UserGroupDto > ( )
446+ . WhereIn < User2UserGroupDto > ( x => x . UserId , ints ) ;
447+ } ) . ToList ( ) ;
450448
451449 if ( groupIds . Any ( ) is false )
452450 {
453451 //this can happen if we are upgrading, so we try do read from this table, as we counn't because of the key earlier
454452 groupIds = user2Groups . Select ( x => x . UserGroupId ) . Distinct ( ) . ToList ( ) ;
455453 }
456454
457-
458455 // get groups
459456 // We wrap this in a try-catch, as this might throw errors when you try to login before having migrated your database
460457 Dictionary < int , UserGroupDto > groups ;
@@ -493,13 +490,13 @@ private void PerformGetReferencedDtos(List<UserDto> dtos)
493490 . ToDictionary ( x => x . Key , x => x ) ;
494491
495492 // get start nodes
496-
497- sql = SqlContext . Sql ( )
498- . Select < UserStartNodeDto > ( )
499- . From < UserStartNodeDto > ( )
500- . WhereIn < UserStartNodeDto > ( x => x . UserId , userIds ) ;
501-
502- List < UserStartNodeDto > ? startNodes = Database . Fetch < UserStartNodeDto > ( sql ) ;
493+ List < UserStartNodeDto > ? startNodes = Database . FetchByGroups < UserStartNodeDto , int > ( userIds , Constants . Sql . MaxParameterCount , ints =>
494+ {
495+ return SqlContext . Sql ( )
496+ . Select < UserStartNodeDto > ( )
497+ . From < UserStartNodeDto > ( )
498+ . WhereIn < UserStartNodeDto > ( x => x . UserId , ints ) ;
499+ } ) . ToList ( ) ;
503500
504501 // get groups2languages
505502
0 commit comments