Tuesday, 15 April 2014

c# - Convert sql to LINQ TOP 1 NOT in -


How do I convert this SQL to LINQ?

  Select the top 1 ID, from the Grad Tbl1 WHERE tbl1.ID (Choose GridId from Tbl2 WHERE id = 99469)    

It seems that the easiest way would be to:

  var grads = (from T in R2 where r. ID == 99469 Choose r.GradID); Var result = (Where in R to TB1! Grods. Select (RIID) Select new {r.ID, r.Grad}) .FirstOrDefault ();   

Or for a little bit more brief:

  var grads = ... var results = tbl1. Select (R = & gt; new {r.ID, R. Grad}). FirstOver Default (R => Grods. Canton (RIID));    

No comments:

Post a Comment