I have 3 tables that I am joining in LINQ, and selecting records from the 3rd. Because I am doing joins, tables 2 & 3 have the same column name at least once (the fk-pk link). What happens is that because I am 'selecting' table 3, the column I need is renamed to MyPK1, and so the object is never correctly populated.
This can be solved by using table_field naming standards, t0_field, t1_field, etc and tracking where the data goes.
from x in Data.TableX.All()
join y in Data.TableY.All() on x.x_pk equals y.x_pk
join z in Data.TableZ.All() on y.MyPK = z.MyPK
select z;
This gives me sql like this, where MyPK1 will not go into the property MyPK, for obvious reasons.
select ...., [t2].MyPK as MyPK1, [t2].FieldA, [t2].FieldB, ... FROM ...
I have 3 tables that I am joining in LINQ, and selecting records from the 3rd. Because I am doing joins, tables 2 & 3 have the same column name at least once (the fk-pk link). What happens is that because I am 'selecting' table 3, the column I need is renamed to MyPK1, and so the object is never correctly populated.
This can be solved by using table_field naming standards, t0_field, t1_field, etc and tracking where the data goes.
This gives me sql like this, where MyPK1 will not go into the property MyPK, for obvious reasons. select ...., [t2].MyPK as MyPK1, [t2].FieldA, [t2].FieldB, ... FROM ...