4
Answers

subQuery using Linq

S VK

S VK

7y
248
1
  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)