1
Good afternoon,
I have a problem to use Entity Framework Core, when I will do a query with includes as below:
var protocolos = _protocoloService.Search(p => p.Active == true,
p => p.Include(l => l.Local)
, tracking: false).ToList();
The json returned by this code is approximately 80mb. I did a test using the following code:
var protocolos = _protocoloService.Search(p => p.Active == true, tracking: false).ToList();
foreach(Protocolo p in protocolos)
{
Local local = _localService.GetById(p.ID_Local).Result;
p.Local = local;
}
The returned json is only 500kb now. Note: I am using Asnotracking.
Does anyone have any suggestions as to what it might be? Thank you
It is probably circular dependency.
– Jéf Bueno
{ opts.SerializerSettings.Formatting = Formatting.None; opts.SerializerSettings.Contractresolver = new Lowercasecontractresolver(); opts.SerializerSettings.Referenceloophandling = Referenceloophandling.Ignore; opts.SerializerSettings.Nullvaluehandling = Nullvaluehandling.Ignore; } This is the json settings I’m using
– Renner Oliveira
Is your Getbyid not asynchronous? You need to add the await, otherwise the API will respond before all queries are performed.
– Rafael