I'm in C# and using Entity Framework with a database-first approach, and I would like to do a query similar to this query but in an asynchronous way:
[Route("api/Tests/get/by/flight/{id}")]
[ResponseType(typeof(Test))]
public IHttpActionResult getByFlightTodayId(int id)
{
var testList = db.Tests.SqlQuery("Select * from Tests where Tests.AircraftId=@id", new SqlParameter("@id", id)).ToList<Test>();
return Ok(testList);
}
I have an example but it returns only one result - not an array.
[Route("api/Tests/get/by/flight/{id}")]
[ResponseType(typeof(Test))]
public async Task<IHttpActionResult> getByFlightId(int id)
{
Test test = await db.Tests.FirstAsync(r => r.AircraftId == id);
if (test == null)
{
return NotFound();
}
return Ok(test);
}
Also, I want to do an inner join query but I don't know how to do this.
Can someone help me?
Thanks
db.Tests.Include(x=>x.TableName)