0

my linq method system from EF6 is returning $ref when I monitor results in fiddler. If I watch the local window in my webapi everything is populated correctly, but not in the actual results that are returned. It only affects the nested entries. anyone know what I am doing wrong? (I created models from database in EF6)

            var student = dbEF.Accounts
                        .Where(x => x.AccountNumber == acctNum)
                        .Select(x => new DTOCrmDetails()
                        {
                            AccountNumber = x.AccountNumber,

                            CommissionId = x.CommissionId,
                            Commission = x.Commission,

                            ManagerID = x.ManagerID,
                            ManagerName = x.Manager.ManagerName,
                            Manager = x.Manager,

                            Employees = x.Manager.Employees,

                            WireInstructionsUSD = x.Manager.WireInstructionsUSDs

                        //Mapping_ManagersExecutingBrokers = x.Manager.Mapping_ManagersExecutingBrokers

                    }).FirstOrDefault();

        return student;

these are my settings.

var json = config.Formatters.JsonFormatter; json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects; config.Formatters.Remove(config.Formatters.XmlFormatter); config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
solarissf
  • 1,199
  • 2
  • 23
  • 58

1 Answers1

0

You need to disable your lazy loading in the entity framework dbcontext.

something like this way:

dbEF.Configuration.LazyLoadingEnabled = false;
GANESH KUMAR
  • 13
  • 1
  • 5
  • I added [JsonIgnore] to the virtual attributes that are not coming up and it is working. Any idea what this does and why it is working now? – solarissf Feb 05 '19 at 19:20