0

I have 2 table having data as dt1 and dt2 on the basis of id

id column1 column2
1   abc

id column1 column2
1           def

How should I can make it as

id column1 column2
1     abc     def

I need a c# code

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160

1 Answers1

1

Answer taken from: https://stackoverflow.com/a/2767742/2537148

var query = database.dt1// your starting point - table in the "from" statement
       .Join(database.dt2, // the source table of the inner join
          post => dt1.id,        // Select the primary key (the first part of the "on" clause in an sql "join" statement)
          meta => dt2.id,   // Select the foreign key (the second part of the "on" clause)
          (dt1, dt2) => new { Dt1= dt1, Dt2= dt2}); // selection
Community
  • 1
  • 1
sebvst
  • 753
  • 1
  • 13
  • 20
  • My actual 2 table name are as dtlocalpath and dtlocalinnerpath but on writing statement as database.dtlocalpath its showing error –  Dec 13 '16 at 12:25
  • U mean i need to take dataContext? –  Dec 13 '16 at 12:27
  • database is has to be defined first as your database connection. If it is called dataContext in your case, yes. – sebvst Dec 13 '16 at 12:28