Skip to content

Support async methods in the IMaterializer #28

Description

@csantero

This is the main reason I am not using JSONAPI.NET's ApiController implementation yet. I have a service layer that has async CRUD methods that I want to await in async WebAPI actions, but the synchronous IMaterializer interface that ApiController<> uses gets in the way.

I propose converting the interface to the following:

Task<T> GetById<T>(params Object[] keyValues);
Task<object> GetById(Type type, params Object[] keyValues);
Task<T> Materialize<T>(T ephemeral);
Task<object> Materialize(Type type, object ephemeral);
Task<T> MaterializeUpdate<T>(T ephemeral);
Task<object> MaterializeUpdate(Type type, object ephemeral);

I think this is better than supporting both sync and async versions of each method, since you can easily wrap a synchronous method result in a Task.FromResult(), if you really need to.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions