We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

EJ2.AspNetCore struggling with JsonSerializationException

Thread ID:

Created:

Updated:

Platform:

Replies:

141466 Dec 13,2018 12:33 AM UTC May 22,2019 04:19 PM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
Tom
Asked On December 13, 2018 12:33 AM UTC

Hello,

I cannot get pastJsonSerializationExceptions when using ef core entities that have cirular references or self references to which many of my models do. I have placed the following line in my startup but this has no effect for syncfusion controls:
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

There are some other solutions like adding [JsonIgnore] to these properties work but this is unworkable because I use database first and often scaffold which removes the attributes. I have also tried usingMetadataType attribute to adorn these properties with [JsonIgnore] but I get a runtime error when doing so indicating that System.ComponentModel.DataAnnotations cannot be loaded. I have also tried ModelMetadataType but that did not work and I don't like the idea of referencing Asp.NetCore in my entity library just to add this attribute.

The only other option would be to create new classes but I would need to pretty much duplicate my whole model and then updating the model I would need to copy the data from the classes to the model classes. This is a lot of work just to get around Json serialisation errors. Is there a possibility of setting an option in the syncfusion library to ignore ReferenceLoopHandling?

Madhu Sudhanan P [Syncfusion]
Replied On December 13, 2018 12:20 PM UTC

Hi Demetrio, 
 
Thanks for contacting Syncfusion support. 
 
Currently we cannot provide serialization settings to the serialization used by EJ2 controls. Using ViewModel concept is the one of the recommended solution to avoid this exception. Also for updating the entity there is no need to use the ViewModel instead you can simply use the original entity class. If you have faced any difficulties in updating please let us know we will be help you out. 
 
Regards, 
Madhu Sudhanan P 


Karl Heinz Brehme
Replied On May 15, 2019 02:51 AM UTC

Hi, is really annoying to have all database in my hand with Context, and simply do a query object with Linq on EntityFramework and I can't bind the result on a grid showing fields from many objects like a normal database query, because we have to build a new class just to show data on a grid and repeat code...

I think Syncfusion could do something to make this more clean in this matter.


Hariharan J V [Syncfusion]
Replied On May 22, 2019 04:19 PM UTC

Hi Demetrio,

Greetings from Syncfusion,

Currently we do not have support to achieve your requirement “Serialization support for datasource object in ASP.NET Core “ but we have logged a feature request on this and it can be tracked through our feedback portal below.

Link : https://www.syncfusion.com/feedback/6417/serialization-support-for-datasource-object-in-asp-net-core  

If you have any more specification/suggestions to the feature request you can add it as a comment in the portal.

Thanks,
Hariharan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon