This is a migrated thread and some comments may be shown as answers.

How to convert SQL query to Linq query

1 Answer 146 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chieu
Top achievements
Rank 1
Chieu asked on 10 Sep 2011, 12:52 PM
create table table1
(
BienLaiID int,
SoTien money,
NhomID int
)
insert into table1
select 1, 50, 1
union all
select 1,10,1
union all
select 2,100,2
union all
select 3,90,3

Create table table2
( NhomID int
)

insert into table2
select 1
union all
select 2
union all
select 3
union all
select 4
union all
select 5


with t1 as
(
select distinct BienLaiID
from table1
)

select t1.BienLaiID, table2.NhomID, table1.SoTien
from t1
cross join table2
left join table1 on t1.BienLaiID = table1.BienLaiID and table2.NhomID=table1.NhomID

//----
How to turn on sql query syntax to query in linq?
Thanks!

1 Answer, 1 is accepted

Sort by
0
Kosta Hristov
Telerik team
answered on 14 Sep 2011, 04:48 PM
Hello Chieu,

Unfortunately, the query you have provided has no simple representation in LINQ. In order to help you, I will need  more details on what exactly you are trying to achieve, can you provide me with more information ?

I'm looking forward to your answer.

Best wishes,
Kosta Hristov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

Tags
LINQ (LINQ specific questions)
Asked by
Chieu
Top achievements
Rank 1
Answers by
Kosta Hristov
Telerik team
Share this question
or