How To Use The Specification Design Pattern With EF Core 6

preview_player
Показать описание

The Specification design pattern allows us to describe a query in an object. In this video, I'll show you how to implement your own Specification pattern with EF Core. This will improve our existing repository pattern implementation with EF Core.

One Trick To Improve Entity Framework Performance

Join my weekly .NET newsletter:

Read my Blog here:

Subscribe for more:

Chapters
0:00 Implementing the Specification base class
5:35 Concrete Specification implementation
7:14 Implementing the Specification Evaluator
10:54 Applying the Specification in a Repository
15:19 Extending the Specification to support Query Splitting
16:51 How the Specification works
Рекомендации по теме
Комментарии
Автор

What is the point of Specifications, because what I see is that you are replacing 3-5 lines of explicit dbContext querying with multiple classes just to encapsulate a set of expressions applied to dbContext?

PaulSebastianM
Автор

Everytime I watch your videos, it makes me feel that I have not worked in the right way at all. Keep it up, Milan ❤

youssefwael
Автор

Thank you for this video!
In the Domain-Driven Design Fundamentals course on pluralsight, it says that specifications should belong in the domain model. This is to keep business logic out of persistence layer. I think it is another advantage of using the specification pattern :)

DavidGagne
Автор

I think part of the point of specifications is that you don't keep adding (OPEN CLOSED) methods to your repo, but accept the specifications which extend your repository. But, you just rewrote your repo methods to call your specifications when I don't think really shows off the power of this pattern.

pilotboba
Автор

awesome Milan, in very short time your channel getting popular because it is due to you hard work and dedication.
I like your teaching way. it is really understandable.

SajidAliSoftwareEngineer
Автор

Good video and interesting pattern. I like that it makes the repository class cleaner but it does feel like entity framework with a lot of extra steps.

harmroerdink
Автор

Hi Milan, thanks for your ideas and videos. Imho, using Repository pattern in case of EF is already Over engineering. Anyway, thank you for opening the real example of specification pattern itself.

serb
Автор

Hello Milan. Thank you very much for this video. Now I combine the generic repository pattern with the specification pattern to make my hexagonal architecture simpler and more maintainable 🙌🏼🙌🏼👏🏻👏🏻

cbo
Автор

Nice job explaining this somewhat important topic. I’d rather return the task rather than overusing the async/await in your repository.
Thank you

markmbouma
Автор

Great video. This was the one I was looking for after last video.

sampleuser
Автор

Really? Yesterday I was looking for this in your channel and didnt find it. And today you posted it. 😂 Thank you for all your videos

vitorpascoaI
Автор

We use this everywhere at work and it always puzzled me, like, a lot. This is a really good explanation of it, but I still wonder why some folks like this so much.

StephenOwen
Автор

Amazing so many ideas comes to mind just watching this video, nested IncludableQueryable, Projections, etc .. thanks milan.

mohamed-hassan-
Автор

I always love your videos. Always simple and important.

muradhossen
Автор

Hello Milan, thanks for the video, great effort and well explained.
Can you please address the case when I need to use the (ThenInclude) functionality of ef core in this pattern

again thanks

waleed-alshinawi
Автор

12:35 did you say simplify? IMO, honestly, it looks like a lot of ceremony replacing something that was much more explicit and clear.

PaulSebastianM
Автор

Very valuable and useful video.
Thank you for sharing.

talkathiriify
Автор

Great video, thanks for sharing! I just have a quick question: why should we use Expression<Func> instead of just Func? Is it because EF uses expressions to convert LINQ to SQL?

gibran
Автор

Hello Milan. Thanks for the video.
It looks like I missed what was the reason to implement Specification Pattern here.
In generally Specification pattern here is a wrapper on IQueryable which allows you do not depend on EF Core and implement Queries on business logic level and potentially you can use the same specifications for Mongo database (as an example).
But what problem was solved in this case?
I'm asking because I've heard about that approach many years ago, but didn't find a reason to apply into my project because no understanding why this is better then what you had before or bettern then extension methods.
Thanks!

volodymyrliashenko
Автор

Great video, thanks a million for sharing it with us.

nourhannehigazy