Gives you the possibility to strip the data you want to send based on the query of the client using DTOs.
The OfferingSolutions.Datashaper is available on Nuget:
http://www.nuget.org/packages/OfferingSolutions.DataShaper/
http://www.fabian-gosebrink.de/Projects/Datashaper https://github.com/FabianGosebrink/OfferingSolutions-DatashaperDemo
public IHttpActionResult Get(string fields = null)
{
try
{
//...
List listOfFields = new List();
if (fields != null)
{
listOfFields = fields.Split(',').ToList();
}
IQueryable myItems = _repository.GetMyItems();
//...
var result = myItems
.ToList()
.Select(x => Datashaper.CreateDataShapedObject(x, listOfFields));
return Ok(result);
}
catch (Exception)
{
return InternalServerError();
}
}
Now you can shape your data based on the fields you send with your request.
GET /api/test?fields=Id,Title,Date
GET /api/test?fields=Id,Title,Date,ChildClasses.Description,ChildClasses.Id
Have fun!