Query Fails -> Incoming Request has too Many Parameters

Posts   
 
    
Posts: 10
Joined: 12-Dec-2016
# Posted on: 10-Jan-2017 20:03:52   

Is there any other way to write this query? I am trying to page through users, grabbing their related data with the PathEdge, but I am getting an exception too many Parameters. PersonRepository.GetAllPersons() is just returning LinqMetaData.Persons. Thanks!

I need to grab all the navigation data, so I am not generating 1000's of SQL calls in the processing loop.

I am referencing assemblies SD.LLBLGEN.Pro.LinqSupportClasses.NET35, SD.LLBLGEN.ORMSupportClasses.NET20


  int totalCount = PersonRepository.GetAllPersons().Count(x => x.PrimaryCustomerGuid == CustomerGuid);
            int pageSize = 5000;
            int page = 1;
            int totalPages = totalCount / pageSize;
            
            while (page < totalPages)
            {
                var persons = PersonRepository.GetAllPersons()
                   .WithPath(
                       new PathEdge<PersonEntity>(PersonEntity.PrefetchPathPersonRoles),
                       new PathEdge<PersonEntity>(PersonEntity.PrefetchPathPersonBusinessUnits),
                       new PathEdge<PersonEntity>(PersonEntity.PrefetchPathPersonMetaDatas),
                       new PathEdge<PersonEntity>(PersonEntity.PrefetchPathPersonChildCustomers))
                   .Where(p => p.PrimaryCustomerGuid == CustomerGuid)
                   .OrderBy(p => p.Email)
                   .TakePage(page, pageSize)
                   .ToList();

                foreach (var person in persons)
                {
                    pipeline.Execute(person.BusinessUnitRequest());
                }
                page++;
            }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 11-Jan-2017 17:14:11   

Paging with prefetch paths only works with parameterized threshold set to the pagesize. As your page size is 5000, you have had to set it to 5000 as well. Which gives a problem as the max # of parameters in a query is 2100 on sqlserver.

So you have to lower your page size to below that number.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 10
Joined: 12-Dec-2016
# Posted on: 11-Jan-2017 18:55:51   

Otis wrote:

Paging with prefetch paths only works with parameterized threshold set to the pagesize. As your page size is 5000, you have had to set it to 5000 as well. Which gives a problem as the max # of parameters in a query is 2100 on sqlserver.

So you have to lower your page size to below that number.

Ok, Thanks! I have it set at 1000 now, and it is working well.