Open devbrsa opened 1 year ago
You can use custom serializer https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.serializer?view=azure-dotnet in .Net SDK. May be that would help you.
@sourabh1007 Please refer to https://github.com/Azure/azure-cosmos-dotnet-v3/blob/9f8d84860d3170d8a95b278a51ac2792a927a1ab/Microsoft.Azure.Cosmos/src/Linq/ExpressionToSQL.cs#L778C60-L778C60
It remains set to "Newtonsoft" when using JsonConvert.SerializeObject
, even though altering the serializer won't resolve the problem; it's merely a temporary measure to bypass the loop, if necessary.
Stacktrace
Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'DeclaringType' with type 'Microsoft.OData.Edm.EdmComplexType'. Path 'TypedProperty.SchemaElements[0].DeclaredProperties[0]'.
If you're looking for a temporary solution, consider converting the OData syntax tree expression into a CosmosDb query. This can then be used alongside the CosmosDb SDK's QueryDefinition
.
Description: A JsonSerializationException is occurring when using OData queries in the Azure Cosmos DB LINQ provider. This issue is specifically related to the detection of a self-referencing loop during JSON serialization, particularly within the DeclaringType property of type
Microsoft.OData.Edm.EdmComplexType
in the object structure.Assemblies Affected:
Framework:
Dependencies:
Issue Details: When executing OData queries against Azure Cosmos DB using the LINQ provider, a JsonSerializationException is thrown due to the detection of a self-referencing loop during JSON serialization. The issue appears to be related to the DeclaringType property of the
Microsoft.OData.Edm.EdmComplexType
within the object structure.Steps to Reproduce: In the OData repo issue: https://github.com/OData/AspNetCoreOData/issues/1056
Expected Behavior: The expected behavior is to permit the projection of solely the chosen
User
or its internal properties while avoiding the JsonSerializationException.Additional Information:
MaxDepth
property onJsonSerializerSettings
to different values, such as 5, does not seem to have any effect. (Changing manually directly from the SDK source code).Reproducible Code: Link to the original issue: https://github.com/OData/AspNetCoreOData/issues/1056
Stacktrace