Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.7 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.7 KB

OfferingSolutions Datashaper

NuGet Downloads NuGet Version

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

Nuget

The OfferingSolutions.Datashaper is available on Nuget:

http://www.nuget.org/packages/OfferingSolutions.DataShaper/

Demos

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();
    }
}

datashaping-picture1 datashaping-picture2 datashaping-picture3

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!