ef6 linq method returning $ref for nested entries in query

asp.net-web-api2 entity-framework-6 linq


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


        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();
1/31/2019 9:32:47 PM

Popular Answer

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

something like this way:

dbEF.Configuration.LazyLoadingEnabled = false;
2/1/2019 5:05:55 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow