I have a simple API which returns a list of rows from db like so
[HttpGet]
[Route("list/{count}")]
public async Task<ActionResult<IEnumerable<IResult>>> GetRows(int count)
{
var list = await dbc.GetList(count);
return new JsonResult( list.ToList<IResult>() );
}
the database returns a row with attributes id, name, status etc. whereas the interface has a subset like so
public class Result{
int id {get;set;}
string name {get;set:}
int status {get;set;}
}
public interface IResult{
int id {get;set;}
string name {get;set:}
}
I have the .ToList() to return only the fields in the json result, is there a better/more efficient way than to convert to another List() first ?