This is a twist on the solution in EF Core 6 and DDD Pluralsight course repo.
Here, I have added a more intelligent search and a UI (a pair in fact) for the dotnet FWDays '23 presentation, Applying DDD Thinking to EF Core Search Filters The demo is also the focus on an upcoming issue of CODE Magazine.
The two branches
- UsingASearchContext has all of the extra solution logic from the course such as unit tests, integration tests, event handlers etc.
- SearchContextLite is trimmed down with only the necessary logic to focus on the search demo.
Two ways to filter
- The first is via the Home page and lets you perform one filter at a time. Those filters eventually call individual stored procedures.
- The second is via the Flex page and lets you combine filters and leans on specification pattern via a search class. That filtering leads to a single , complex stored proc but the code in the ContractSearchFlexService is incredibly simple as a result.
Creating the database The application startup will check for the existence of the database (demo uses SQL Server localdb). The db name and connection string are in appsettings of the UI project. If there is no database or if it exists with zero rows in the Contracts table, it will recreate the database and seed it with data for 7 contracts. Note that creating or migrating a database in startup is not recommended for production apps that could have multiple instances. But for the purpose of this demo, it's perfectly ok to do. Just sayin' ....