Open Closed

Error with returning IQueryable object from application service #9497


User avatar
0
Spospisil created

Hi,

I am trying to return from my application service an IQueryable<DataDictionary> so that I can use DevExpress's Blazor WASM grid for large datasets (https://demos.devexpress.com/blazor/Grid/DataBinding/LargeQueryable)and I am getting the error below in my application service.

Any idea what the underlying problem is and how I can fix it? I've given access to the private repository with a sample project to @maliming

Steps to Reproduce.

  1. Run migrator project create SQL database/Tables
  2. Run the DataDictionaryInsers.sql statements in SSMS against the DB just created
  3. Launch the solution and log in as host admin (typical credentials)
  4. Go to the /DataMigration page

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: The collection type 'System.Linq.IQueryable1[AbpSolution1.DataDictionaryDto]' is abstract, an interface, or is read only, and could not be instantiated and populated. Path: $ | LineNumber: 0 | BytePositionInLine: 1. System.NotSupportedException: The collection type 'System.Linq.IQueryable1[AbpSolution1.DataDictionaryDto]' is abstract, an interface, or is read only, and could not be instantiated and populated. Path: $ | LineNumber: 0 | BytePositionInLine: 1. ---> System.NotSupportedException: The collection type 'System.Linq.IQueryable1[AbpSolution1.DataDictionaryDto]' is abstract, an interface, or is read only, and could not be instantiated and populated. --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack& state, Utf8JsonReader& reader, Exception innerException) at System.Text.Json.ThrowHelper.ThrowNotSupportedException_CannotPopulateCollection(Type type, Utf8JsonReader& reader, ReadStack& state) at System.Text.Json.Serialization.Converters.IEnumerableOfTConverter2[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].CreateCollection(Utf8JsonReader& reader, ReadStack& state, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonCollectionConverter2[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, IQueryable1& value) at System.Text.Json.Serialization.JsonConverter1[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, IQueryable1& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter1[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ReadCore(Utf8JsonReader& reader, IQueryable1& value, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.Metadata.JsonTypeInfo1[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].Deserialize(Utf8JsonReader& reader, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[IQueryable1](ReadOnlySpan1 utf8Json, JsonTypeInfo1 jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[IQueryable1](ReadOnlySpan1 json, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[IQueryable1](String json, JsonSerializerOptions options) at Volo.Abp.Json.SystemTextJson.AbpSystemTextJsonSerializer.Deserialize[IQueryable1](String jsonString, Boolean camelCase) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.<RequestAsync>d__351[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptorClientProxy1.<CallRequestAsync>d__01[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.<CallRequestAsync>d__261[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.<GetResultAsync>d__27[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.<InterceptAsync>d__24[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__31[[Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Volo.Abp.Http.Client, Version=9.1.1.0, Culture=neutral, PublicKeyToken=null],[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__141[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.<ProceedAsync>d__7[[System.Linq.IQueryable1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__31[[Volo.Abp.Validation.ValidationInterceptor, Volo.Abp.Validation, Version=9.1.1.0, Culture=neutral, PublicKeyToken=null],[System.Linq.IQueryable`1[[AbpSolution1.DataDictionaryDto, AbpSolution1.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Linq.Expressions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at CFData.Structure.Lexicon.Blazor.DataDictionaryManagement.GetEntitiesAsync() in D:\ABPSample4\AbpSolution1\src\AbpSolution1.Blazor.Client\Pages\DataDictionaryManagement.razor.cs:line 40 at CFData.Structure.Lexicon.Blazor.DataDictionaryManagement.OnInitializedAsync() in D:\ABPSample4\AbpSolution1\src\AbpSolution1.Blazor.Client\Pages\DataDictionaryManagement.razor.cs:line 31 at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)


15 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    The error occurs because returning IQueryable<T> directly from an ABP application service (or any Web API) is not supported. IQueryable is an interface and cannot be serialized/deserialized over HTTP, which is why you see the "could not be instantiated and populated" exception. ABP's dynamic HTTP API client and System.Text.Json cannot handle IQueryable<T> as a return type.

    To work with large datasets in Blazor (including DevExpress or other grids), you should implement server-side paging, sorting, and filtering in your application service. Instead of returning IQueryable<T>, return a paged result (such as a List<T> or a PagedResultDto<T>) from your application service.

    Example:

    public async Task<PagedResultDto<DataDictionaryDto>> GetListAsync(PagedAndSortedResultRequestDto input)
    {
        var query = _dataDictionaryRepository
            .WhereIf(!input.Filter.IsNullOrWhiteSpace(), x => x.Name.Contains(input.Filter));
        var totalCount = await query.CountAsync();
        var items = await query
            .OrderBy(input.Sorting ?? "Name")
            .Skip(input.SkipCount)
            .Take(input.MaxResultCount)
            .ToListAsync();
    
        return new PagedResultDto<DataDictionaryDto>(totalCount, ObjectMapper.Map<List<DataDictionary>, List<DataDictionaryDto>>(items));
    }
    

    On the Blazor client, use the grid's "load data" event to call this paged API and bind the result.

    This is the recommended and supported approach in ABP for large data grids.

    No verified source available for this specific query.


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    Spospisil created

    I've adjusted my solution as was suggested and while I do not get the error I was once getting the grid still does not load the grid with the first 20 rows of the dataset and allow me to page to the next 20, etc. As I mentioned in my initial ticket, we are using DevExpress datagrid not the Blazorise grid.

    I have updated the git repo with the implemented suggestion

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Any idea what the underlying problem is and how I can fix it? I've given access to the private repository with a sample project to @maliming

    Where is your repository?

    Thanks.

  • User Avatar
    0
    Spospisil created

    ? You accepted the invite to git repo already.

    https://github.com/spospisil/AbpGridSolution

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I asked the question URL https://github.com/spospisil/AbpGridSolution/issues/1

    Can you get DataDictionaryList in your blazor page now?

    var result = await DataDictionaryAppService.GetListAsync(input);
    DataDictionaryList = (List<DataDictionaryDto>)result.Items;
    

    If so, the backend is working. You can check DevExpress document to show the data.

    I don't have much experience with DevExpress.

    Thanks.

  • User Avatar
    0
    Spospisil created

    Your questions don't make sense!!! You have the support ticket URL because you are replying to me on it right now!!!!

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I received an invitation from GitHub, but I don't know the question URL. There are many questions on the support website.


    Can you get DataDictionaryList in your blazor page now?

  • User Avatar
    0
    Spospisil created

    ? Maliming. You are replaying to the support ticket now!!!!!! My issue I'm having is at the top!!!!!! Why would the datadictionarylist work now? Did you make any changes to the code to get it to work?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What I mean is, I had no idea three days ago.

    If you invite me again later, please provide the URL for the support question.

  • User Avatar
    0
    Spospisil created

    OMG!!!!! But you know now right? What is unclear to you? You have the support ticket url (because you're replying to it) and you have access to the source code? Why are you confused?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You've already modified the code based on the AI's response so that the System.NotSupportedException: The collection type 'System.Linq.IQueryable error no longer appears.

    My question is: can you get the data returned by the application service on your blazor page?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Spospisil :No, I still cannot get data returned to the blazor page because now I'm encountering this error. I have changed the MaxResultCount and MaxMaxResultCount properties in several ways and I'm still getting this error. I have 50,000 rows in my database table and I'm trying to return all of them (for performance testing reasons) and it keeps popping up with the below error.

    Can you tell me what's wrong with the sample project's code?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can increase LimitedResultRequestDto.MaxMaxResultCount number.

    See https://abp.io/docs/latest/framework/architecture/domain-driven-design/data-transfer-objects#max-result-count

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I pushed my changes. https://github.com/spospisil/AbpGridSolution/pull/2

    1.The [RemoteService(IsEnabled = false)] need to be removed. 2. Application service can't return Task<IQueryable<DataDictionaryDto>> , Blazor will use ajax to get data. It doesn't support IQueryable, Blazor is a pure UI project.

    Now API can return the data.

  • User Avatar
    0
    Spospisil created

    Hi,

    Ended up going a different route to implement large dataset retrieval and loading into the DevExpress Blazor grid based on the great advice of the DevExpress support team. They responded with a comprehensive explanation of their product with regards to what I was trying to accomplish. Great support folks there for sure.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on July 09, 2025, 06:20