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.
- Run migrator project create SQL database/Tables
- Run the DataDictionaryInsers.sql statements in SSMS against the DB just created
- Launch the solution and log in as host admin (typical credentials)
- 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.IQueryable
1[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.IEnumerableOfTConverter
2[[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.JsonCollectionConverter
2[[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, IQueryable
1& value)
at System.Text.Json.Serialization.JsonConverter1[[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]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, IQueryable1& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter
1[[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, IQueryable
1& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo1[[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]].Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[IQueryable1](ReadOnlySpan
1 utf8Json, JsonTypeInfo1 jsonTypeInfo, Nullable
1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[IQueryable1](ReadOnlySpan
1 json, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[IQueryable
1](String json, JsonSerializerOptions options)
at Volo.Abp.Json.SystemTextJson.AbpSystemTextJsonSerializer.Deserialize[IQueryable1](String jsonString, Boolean camelCase) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase
1.<RequestAsync>d__351[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.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 Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptorClientProxy1.<CallRequestAsync>d__0
1[[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.DynamicHttpProxyInterceptor
1.<CallRequestAsync>d__261[[AbpSolution1.IDataDictionaryAppService, AbpSolution1.Application.Contracts, Version=1.0.0.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 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.DynamicHttpProxyInterceptor
1.<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__3
1[[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.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 Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__141[[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 Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.<ProceedAsync>d__7[[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 Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__3
1[[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)
-
0
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.
-
0
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
-
0
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.
-
0
? You accepted the invite to git repo already.
https://github.com/spospisil/AbpGridSolution
-
0
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.
-
0
Your questions don't make sense!!! You have the support ticket URL because you are replying to me on it right now!!!!
-
0
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? -
0
? 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?
-
0
-
0
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?
-
0
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?
-
0
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?
-
0
-
0
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 returnTask<IQueryable<DataDictionaryDto>>
, Blazor will use ajax to get data. It doesn't supportIQueryable
, Blazor is a pure UI project.Now API can return the data.
-
0
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.