Before updating scaffolding from new db schema try creating is bill anderson married or dating

Rated 4.16/5 based on 667 customer reviews

However the issue is – what replaces the good bits of the repository, like handling Domain-Driven Design (DDD) which tries to treat the data persistence library as a simple in-memory collection.

This means we want to hide some of EFs code, but still be able to use all of its features.

I have written two articles that describe the design of the Complex. They are: showing you those query objects in action.

In the first post I mentioned that people were taking about Query Objects, which is an encapsulation of particular database queries or updates.

This needs a bit of thought, but isn’t that hard to do.

By using LINQ and IQueryable requests then this allows paging and filtering to be added at the last minute in the UI/Web Api end. Select function allows only the columns/properties you need to be read in. The result is an Open Source library called Generic Services which provides List, Detail, Create, Update and Delete functions on either the EF data classes themselves or more interestingly via DTOs linked to EF data classes. Sample Mvc Web App, which is a much more realistic example of a real application.

Therefore the business layer will use the data classes directly, as they are a good fit to the business problem.

I still use a DDD approach, but I have found that EF doesn’t really support a pure DDD design for a number of reasons.

before updating scaffolding from new db schema try creating-74

before updating scaffolding from new db schema try creating-68

before updating scaffolding from new db schema try creating-17

This post details my new approach to using EF and why it is better.

DDD recognises that there might need to be some implementation compromises to work with the database, but the overall aim is to keep the focus on the business problems.

The other issue that effects the approach used is that the actual data saved in the database will be designed for the business layer.

This code would be in the data/infrastructure layer, which means the EF code is more centralised in one place. While DDD accepts that the way data is stored/persisted will have an affect on the design (see Eric Evans book, page 159) the aim is to allow Business Layer code treat the database as an in-memory collection which some search procedures, with as little interaction as possible with the data access code.

I would recommend Edward Charbeneau‘s article ‘Giving Clarity to LINQ Queries by Extending Expressions‘ which has some excellent ideas and source code for building ‘query objects’. This isn’t done just to hide the database, but mainly to ensure that the developers working in the business layer are thinking about the business problem first, not how the database works.

Leave a Reply