问题
I have a few tables in my database which are mapped to an edmx. Using the entity framework to return data from these tables, I've encountered a problem where the value in the "name" column from one of my higher level data models is being populated into each model below it.
I'm pulling the data like this:
var query = (from a in context.things
where a.id == 1
select a);
var model = query.Select(a => new modelA()
{
Name = a.name,
Bs = a.Bs.Select(b => new modelB()
{
Name = b.name,
Cs = b.Cs.Select(c => new modelC()
{
Name = c.name,
Ds = c.Ds.Select(d => new modelD()
{
Name = d.name
})
})
})
}).FirstOrDefault();
b.name, c.name and d.name are all returning the same value as a.name despite my database definitely having different values in across these tables.
Could this be a caching issue?
Update
After upgrading the mySql connector to the latest version (6.7.4.0) I am still encountering the error.
After the upgrade it seems i can get 3 levels deep before the data in the name column starts reappearing :(
来源:https://stackoverflow.com/questions/19007589/entity-framework-returning-incorrect-data-from-columns-with-same-name