I need to convert this SQL query into LINQ EF version.
select evraklar.* from `numune_sahipleri`
join `evraklar` on `numune_sahipleri`.`evraklar_id`=evraklar.`evraklar_id`
join `sevkedilen_lablar` on `evraklar`.`evraklar_id`=`sevkedilen_lablar`.`evraklar_id`
where birimler_id=1 and `numune_sahipleri`.adisoyadi like ('%Name%');
but no luck trying to convert it using include and theninclude and where (which is obviously not working after theninclude)
Member
92 Points
534 Posts
Can anyone be darling and convert this SQL query to Linq and EF
Jun 28, 2019 06:39 AM|fatihbarut|LINK
Hi all,
I need to convert this SQL query into LINQ EF version.
select evraklar.* from `numune_sahipleri`
join `evraklar` on `numune_sahipleri`.`evraklar_id`=evraklar.`evraklar_id`
join `sevkedilen_lablar` on `evraklar`.`evraklar_id`=`sevkedilen_lablar`.`evraklar_id`
where birimler_id=1 and `numune_sahipleri`.adisoyadi like ('%Name%');
but no luck trying to convert it using include and theninclude and where (which is obviously not working after theninclude)
All-Star
53751 Points
24070 Posts
Re: Can anyone be darling and convert this SQL query to Linq and EF
Jun 28, 2019 10:36 AM|mgebhard|LINK
The pseudo SQL is not complete. We can accurately answer this question if you share the Entities.
The EF documentation covers joins and joins and the pattern is pretty simple.
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ef/language-reference/query-expression-syntax-examples-join-operators
Member
92 Points
534 Posts
Re: Can anyone be darling and convert this SQL query to Linq and EF
Jun 28, 2019 10:43 AM|fatihbarut|LINK
can't we solve the problem using include and then include instead of joins?
All-Star
53751 Points
24070 Posts
Re: Can anyone be darling and convert this SQL query to Linq and EF
Jun 28, 2019 10:53 AM|mgebhard|LINK
Sure, the Include() extension loads related data but you have not shared the Entities (or sample code) which contain the navigation properties.
Include reference documentation
https://docs.microsoft.com/en-us/ef/core/querying/related-data