I have a simple SQL query:
SELECT table1.[idGK] , table2.FullName , table2.LgotName
from table2
join table1 on table2.C_LGT = table1.[idGK]
where table1.mcod = 41003
And I have the correct conclusion:
idGK | FullName| LgotName
------------------------
1 |One |Ball
2 |Two |Wog
3 |Three |Aks
5 |Four |Mqi
7 |Five |Thel
9 |Six |Imx
But when I make a LINQ query of this:
IEnumerable<FinalDoc> fidn = from post in repository.table1
join thir in repository.table2 on post.idGK equals thir.C_LGT
where post.mcod.Trim().Contains("41003")
orderby post.idGK
select new FinalDoc
{
mcod = post.mcod,
FullName= thir.FullName,
idGK = post.idGK
};
I have this result:
FullName | LgotName
------------------------
Five |Thel
Five |Thel
Five |Thel
Five |Thel
Five |Thel
Five |Thel
I am trying to modify table1 and table 2 to make the correct connection, but I have the same result.
What linq query do i need to make the same result as in SQl?
PS EF, Linq, Asp.net, web forms
source
share