S VK

S VK

  • NA
  • 18
  • 0

subQuery using Linq

Oct 26 2017 12:28 PM
  1. // sql returns records  
  2.   
  3. SELECT * FROM InfoDetails WHERE InfoId =( SELECT tOP 1 InfoId FROM InfoMaster WHERE recordid=1 ORDER BY  CreationDate  DESC)  
  4.       
  5. // returns 0 records  
  6.   
  7.     db.InfoDetails.Where(u => u.InfoId ==(db.InfoMaster  
  8.                   .Where(x => x.recordid == Id).OrderByDescending(x => x.CreationDate).Select(x => x.InfoId).FirstOrDefault()))  
  9.                   .Select(t=> new InfoListViewModel  
  • i need the above sql as linq lambda expression

    sql returns reocrds but linq returns 0


Answers (4)