Composing queries with commands

We will streamline the implementation while implementing commands in our repository. The following code will allow us to create an interface which enforces IncludeData to be set for all queries:

   public interface IQueryRoot   {      bool IncludeData { get; set; }   }

We will use IQueryRoot as a base interface for the query handler, which returns generic return typed data. The following code extends the IQueryRoot and provide two interfaces to support synchronous and asynchronous operations:

    public interface IQueryHandler<out TReturn> : IQueryRoot    {      TReturn Handle();    }    public interface IQueryHandlerAsync<TReturn> : IQueryRoot    {      Task<TReturn> HandleAsync();    }

Let's keep creating multiple generic interfaces required for ...

Get Mastering Entity Framework Core 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.