What's New with Mendz.Data.Repository(.Async)

Mendz.Data.Repository defines the CRUDS interfaces. Mendz.Data.Repository.Async defines the async versions of the CRUDS interfaces. The new CRUDS signatures add more features and flexibility. Here are the highlights.

Now let's be clear. The Mendz.Data tools and guidance are NOT and DO NOT claim to be implementations of the repository pattern. I just called the Mendz.Data.Repository namespace that for the lack of a better name. In usage, the Mendz.Data.Repository(.Async) interfaces are exactly what they are intended to be: to provide the guiding signatures for containing, defining and implementing CRUDS operations. In this sense, my use of the word "repository" or "repositories" refers to classes that implement the Mendz.Data.Repository(.Async) CRUDS interfaces.

CRUDS stand for Create, Read, Update, Delete and Search. In this context, R-Read refers to retrieving a single record; S-Search refers to retrieving a list of records. The CRUDS interfaces are designed to let developers create repositories that implement only the CRUDS methods that the model needs.

In general, the following is the new signature pattern:

T MethodName(T model, dynamic expansion = null, List<ResultInfo> result = null)

For search, the new signature pattern is as follows:

T Search<F, S>(F filter, S sort, dynamic expansion = null, 
    PaginInfo paging = null, List<ResultInfo> result = null)

These new signature patterns are also similarly applied in the async versions.

T MethodNameAsync(T model, dynamic expansion = null, 
    List<ResultInfo> result = null, 
    CancellationToken cancellationToken = default(CancellationToken))

T SearchAsync<F, S>(F filter, S sort, dynamic expansion = null, 
    PagingInfo paging = null, List<ResultInfo> result = null, 
    CancellationToken cancellationToken = default(CancellationToken))

Note that these signatures make the following assumptions:
  • As a reference type, dynamic expansion is passed by reference. If the caller expects dynamic values from the CRUDS method, the caller must create the dynamic expansion instance (ex. dynamic expansion = new ExpandoObject();). Implementations should not overwrite the passed expansion instance/reference.
  • As a reference type, List<ResultInfo> result is passed by reference. In order for the result to "return", the List<ResultInfo> instance should be created by the caller. Implementations should not overwrite the passed result instance/reference.
  • As a reference type, PagingInfo paging is passed by reference. In order for the paging info to "return", the PagingInfo instance should be created by the caller. Implementations should not overwrite the passed paging instance/reference.
The new CRUDS interfaces are more consistent and more flexible to work with, regardless if you are using the synchronous or the asynchronous versions. The new PagingInfo paging parameter extends and simplifies how paging information can be exchanged with the caller. Get Mendz.Data and start using the Mendz.Data.Repository(.Async) CRUDS interfaces in your repository projects.

Comments