-2

I've written this code to join two tables together from sql server, now I want to write this as in method syntax. How can I rewrite this code?

LinqToLoginDataContext lnqdore = new LinqToLoginDataContext();
var f = (from k in lnqdore.Table_Years
         join h in lnqdore.Table_Dores on k.Id equals h.FK_Year
         where h.Id == (int)dataviewDore.CurrentRow.Cells["Id"].Value
         select k).Single();
J. Steen
  • 15,470
  • 15
  • 56
  • 63

1 Answers1

1
var f = lnqdore.Table_Years
    .Join(lnqdore.Table_Dores, k => k.ID, h => h.FK_Year, (k, h) => new { k, h })
    .Where(res => res.h.ID == (int)dataviewDore.CurrentRow.Cells["Id"].Value)
    .Select(res => res.k)
    .Single();
Farhad Jabiyev
  • 26,014
  • 8
  • 72
  • 98
  • 1
    Please do not support this type of questions. Thank you! – walther Aug 14 '14 at 08:50
  • why do not support this type of questions? – user3116296 Aug 14 '14 at 08:55
  • @user3116296 He means that, you can read one of many articles about LINQ method syntax with the help of lambda expressions. And after reading that, you will have better knowledge about it and you will solve your problem for your own. – Farhad Jabiyev Aug 14 '14 at 09:03