How to convert SQL query to Linq query

2 posts, 0 answers
  1. Chieu
    Chieu avatar
    1 posts
    Member since:
    Jul 2010

    Posted 10 Sep 2011 Link to this post

    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?
  2. Kosta Hristov
    Kosta Hristov avatar
    13 posts

    Posted 14 Sep 2011 Link to this post

    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 >>

  3. DevCraft banner
Back to Top