Skip to content

Generic Services meant to help building a service/application layer in a .NET based application

License

Notifications You must be signed in to change notification settings

mario-loza/GenericServices

 
 

Repository files navigation

GenericServices

Generic Services is a .NET class library to help build a service layer, i.e. a layer that acts as a facard/adapter between your business/data service layers and your User Interface or HTTP service. It makes heavy use of Entity Framework 6 - EF6 and .NET 4.5's async/await commands. Its aim is to make the creation of the service layer simple while providing robust implementations of standard database and business object actions. It is an Open Source project.

Go to the live example web site for live demostrations of GenericServices working in an ASP.NET MVC5 application.

What is the motivation behind building GenericServices?

I develop fairly complex analysing, modelling and data visualisation web applications (see Spatial Modeller). These require a Domain-Driven Design approach to the data and business objects, while the visualisation needs a comprehensive user interface which I implement using a Single Page Application - SPA. This means there often a mismatch between what the business/data layers classes and what the user interface needs.

My experience is that the Service Layer, plus Data Transfer Objects - DTOs is the best way to solve this mismatch. However I have found that the service layer is often filled with lots of code that is very similar, with just different data classes. I therefore researched a number of approaches to solve this and finally came up with a solution using C#'s Generic classes. I have therefore called it GenericServices.

Details on GenericServices

Generic Database access commands

GenericServices provides the standard CRUD (Create, Read, Update and Delete) commands using EF 6. These commands have the following features:

  • Standard CRUD commands using EF6 that can link to any class through C# Generics.
  • Can work directly on the class connected to the database OR via a DTO to shape the data.
  • Does automatic, convention-based mapping between data and DTO classes via AutoMapper.
  • Good extension points to handle specific issues like loading a dropdownlist for the UI.
  • There are normal and async versions of all CRUD commands.

What frameworks are GenericServices is designed to work with?

  • GenericServices is designed work as a service layer framework in any .NET application, such as:

  • GenericServices assumed a disconnected state model, e.g. a web site or a Http RESTful service .

  • GenericServices assumes a horizontal scaling model, e.g. scale by having multiple web instances.

  • GenericServices uses the following .NET frameworks/systems.

    • It needs .NET 4.5 for the new async/await tasking format introduced in .NET 4.5
    • It uses Entity Framework 6 for database access, again because it supports async commands.
    • It also makes use of the open source AutoMapper library for transforming data to/from DTOs.

General items

  • GenericService is designed to handle validation and error checking at multiple levels in the system.
  • Good examples of usage via an online example web site which includes some documentation.
  • The source code of the example web site is also available as a Open Source project.
  • The commands have been extensively Unit Tested.
  • The project is Open Source.

For documentation on the commands and configuration please look at the wiki plus the example web site listed above.

About

Generic Services meant to help building a service/application layer in a .NET based application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%