-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OData.Client 8.2.1 does not materialize data service responses #3124
Comments
@dotnetero Thanks for reporting this. In the look of the exception thrown, it seems like the issue is on Could you kindly share a CSDL that can help us repro this issue. The one you shared above is not sufficient to repro the issue. It seems like |
Tried OData client 8.2.1 and 8.2.2 against the TrippinService and it returned expected resoults. So there could be something else related to this specific scenario that causes things to break. |
The code that you have shared is supposed to be called when the object is an entity type: // inside ObjectMaterializerLog
internal void CreatedInstance(MaterializerEntry entry)
{
// omitted for brevity
if (IsEntity(entry) && entry.IsTracking && !entry.Entry.IsTransient)
{
this.identityStack.Add(entry.Id, entry.Entry);
if (this.mergeOption == MergeOption.AppendOnly)
{
this.appendOnlyEntries.Add(entry.Id, entry.Entry);
}
}
} But in your model, Here's an excerpt of PropertyInfo[] keyProperties;
bool hasProperties;
Type[] hierarchy = ClientEdmModel.GetTypeHierarchy(type, out keyProperties, out hasProperties);
Debug.Assert(keyProperties == null || keyProperties.Length == 0 || keyProperties.All(p => p.DeclaringType == keyProperties[0].DeclaringType), "All key properties must be declared on the same type.");
bool isEntity = keyProperties != null;
keyProperties = keyProperties ?? ClientTypeUtil.EmptyPropertyInfoArray;
foreach (Type t in hierarchy)
{
// Pass in the full list of key properties for the most base type to be added there. We only allow key properties to be
// declared on the same type.
IEdmStructuredType edmBaseType = cachedEdmType == null ? null : cachedEdmType.EdmType as IEdmStructuredType;
cachedEdmType = this.GetOrCreateEdmTypeInternal(edmBaseType, t, keyProperties, isEntity, t == type ? hasProperties : (bool?)null);
// Pass in an empty PropertyInfo array on subsequent derived types.
keyProperties = ClientTypeUtil.EmptyPropertyInfoArray;
} I found an old issue that predicted this problem: #177 Another issue that asks whether the |
https://1drv.ms/u/c/97eaa7be3d6c4d3e/EZtyIUzhfDpPvSn0oZJun_QBbb6cWVmLgPe4IAtyBQthqg?e=AaN4rd Greetings @WanjohiSammy , sorry for the delay, there is some work, I hope the project I share, will allow you to get the necessary information to get to the problem of complex types with a property called Id. |
They have plans to no longer allow Id(ID) or ClassName + Id(ID) name properties in complex types, by modifying projects and removing such properties, everything works fine. I add sample code, so you can observe the problem: |
Good day @WanjohiSammy , an apology, do not check the correct functioning of the link, added the change: https://1drv.ms/u/c/97eaa7be3d6c4d3e/EZtyIUzhfDpPvSn0oZJun_QBbb6cWVmLgPe4IAtyBQthqg?e=AaN4rd |
Assemblies affected
Other libraries used in the project:
Describe the bug
In all requests made by using a unit of work that encapsulates a DataServiceContext, it is not possible to materialize the results, obtaining the same error in all methods "Value cannot be null (Parameter 'key')".
Multiple client applications were programmed on Blazor Server, Wpf Core, among others. These must consume multiple services made with AspNetCore.OData, prior to updating to the assemblies mentioned above, everything worked fine, at this time the calls to the OData services do not materialize.
AspNetCore.OData services work well and return results correctly.
Reproduce steps
Data Model
EDM (CSDL) Model
Request/Response
Request:
Response:
The following image shows that the data service adequately responds to all methods:
The response it´s empty on blazor server app or Wpf app.
Expected behavior
Whether the data service returns IQueryable, Enumerable, List, etc. It is expected to be able to materialize these results for consumption in client applications.
Screenshots
Additional context
If you use Microsoft.OData.Client 8.1.0, everything works as expected. Leaving client applications with Net 9 and data services with AspNetCore.Odata 9.1.0 and EntityFrameworkCore 9.0.0.
The text was updated successfully, but these errors were encountered: