I have written Linq Query that i wanted to make it Lambda Expression. how to write the Lambda Expression in place of return statement Linq Query. entities tables are entities.Users,entities.Users,entities.ponds
Query Expression :
from pond in Ponds
join customerdevice in CustomerDevices on pond.Imei equals customerdevice.Imei
join user in Users on customerdevice.CustomerId equals user.CustomerId
where user.Username=="user1"
select new { temp = pond.Temp, imei = pond.Imei,timestamp=pond.Timestatmp }
Lambda Expression :
public async Task<IHttpActionResult> GetAllData(int deviceid)
{
using (smartpondEntities entities = new smartpondEntities())
{
try
{
return Ok(await entities.ponds.Where(u=>u.deviceid==deviceid).OrderByDescending(u => u.timestatmp).ToListAsync());
}
catch (Exception Ex)
{
return BadRequest("Sorry Error Found!!!");
}
}
}