vendredi 26 mai 2017

Usage dynamic as result for web api

Is it normal practice to return dynamic or get object type in web api controller methods or should i use custom contract types with validating in requests and general "complete code"?

For example here is code snippet:

public dynamic CreateOrUpdate([FromBody]object body)
    {
        return _blService.CreateOrder(body);
    }

CreateOrder performs deserializing and saving and returns Id or error.

Here are other methods returning dynamic data. blService returns different anonymous types for list of object or for single object:

    public dynamic GetOrdersByTypeId([FromQuery]Guid typeId, [FromQuery]int? pageIndex)
    {
        return _blService.GetOrdersByTypeId(typeId, pageIndex);
    }

    public dynamic GetOrderById([FromQuery]Guid id)
    {
        return _blService.GetOrderById(id);
    }




Aucun commentaire:

Enregistrer un commentaire