Skip to content

OfferingSolutions/OfferingSolutions-Datashaper

Repository files navigation

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!

About

Gives you the Datashaping functionality to your WebAPI-Projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages