Datashaper Adds datashaping functionality to your WebAPI

Datashaper

  • Monday
  • 04.05.2015
  • Datashaper

Datashaper

Gives you the possibility to strip the data you want to send based on the query of the client

Download Datashaper
Datashaper at GitHub

WebAPI (Server)

[Route("myroute")]
public IHttpActionResult Get(string fields = null)
{
    try
    {
        //...
        
        List<string> listOfFields = new List<string>();
        if (fields != null)
        {
            listOfFields = fields.Split(',').ToList();
        }

        IQueryable<MyItems> myItems = _repository.GetMyItems();

        //...
        
        var result = myItems
            .ToList()
            .Select(x => Datashaper.CreateDataShapedObject(x, listOfFields));

        return Ok(result);
    }
    catch (Exception)
    {
         return InternalServerError();
    }
}

Consider to use DTO's to send data to the Client. Using "entities" here is only for presenting purposes.


Example-Requests