c# - LINQ select EntityCommandExecutionException -


so. controller:

public device.devicedbcontext db5 = new device.devicedbcontext(); var d1 = d in db5.devices        d.gre == "gre-0495"        select d; doc.devices.add(d1.first()); 

model:

public class doc     {     // unrelated fields omitted      public icollection<device> devices { get; set; }     } 

second model file:

public class device     {        // unrelated omitted        public string gre { get; set; }         public class devicedbcontext : dbcontext        {            public dbset<device> devices { get; set; }        }     } 

i double-checked database device had d.gre == "gre-0495", there. , exact error below. caught inside last line in controller.

'((system.data.entity.dynamicproxies.device_ea17fd29b09167fed4ab0c5ad1e7cf460032c2d49c4002ffbf9d395cb5849d5a)new system.linq.systemcore_enumerabledebugview<steer.models.device>(d1).items[0]).docs' threw exception of type 'system.data.entity.core.entitycommandexecutionexception' 

the breakpoint shows d1 populated correct data gre=="gre-0495".


Comments