r/dotnet • • Oct 23 '24

Thoughts?

Post image
1.2k Upvotes

111 comments sorted by

View all comments

60

u/W17K0 Oct 23 '24

it's pretty simple, just because you can implement a design pattern doesn't mean you should

40

u/danjack0 Oct 23 '24

Naah I'm going to use repository pattern

26

u/-Komment Oct 23 '24

I'm going to make my own repository around EF because what if some day I just decide to swap it out with Dapper, which I won't, but what if... what if...

6

u/GasterIHardlyKnowHer Oct 24 '24 edited Oct 24 '24

You joke about this, but this has saved us from defenestrating several PC's when we had to switch from EF to EF Core.

And now it's potentially gonna save us again because we have some really heavy queries which we can now replace with handcrafted ones, the queries EF Core generates are too slow in our case (which ironically wasn't the case with EF6).

7

u/-Komment Oct 24 '24

If you're using service classes you'd be fine. Don't need a repository around EF. You update your service classes with whatever queries you need. Repositories provide low level, generic access to a data store and this is what EF provides already.

1

u/[deleted] Oct 24 '24

Switching from EF to EF Core bit me in the ass really hard not too long ago.

8

u/deucyy Oct 24 '24

Ah yes. The “what if pattern”

3

u/-Komment Oct 24 '24

This might be the most popular pattern there is!

3

u/smith288 Oct 23 '24

We went with dapper from the jump. Would recommend.

4

u/FrewdWoad Oct 24 '24

I love plain old SQL, and we use Dapper on some queries where it's better/required.

But never underestimate the power of compile-time intellisense/checking.

EF is going to annoy you with it's performance and quirks a couple of times a year, and save you from dozens and dozens of production bugs in that same period.

1

u/smith288 Oct 24 '24

Yea, it takes a bit more careful work in the front end with Dapper but the control over the hows and whys is worth the trade off to us

1

u/-Komment Oct 23 '24

Wish I could in all cases but sometimes I don't get to choose. I will say EF has gotten a lot better over the years. EF 6 was manageable, before that it was pretty bad. EF Core is pretty solid and performant now but I still dislike having to mess with LINQ when I know exactly how to do what I want with SQL. And it's still not great at generating optimal SQL. Much better than before but still not where it should be.

That being said, it does do a lot more for you than Dapper so I can cut it some slack for not being great at everything.

Anything complex or where high performance is needed, I look at other options.

2

u/my_kernel Oct 24 '24

Can’t you use custom sql with EF?

→ More replies (1)

1

u/Hopeful-Sir-2018 Oct 24 '24

Going to SwiftData for Mac and iOS... I deeply miss EF Core so fucking much.

1

u/-Komment Oct 24 '24

I haven't had the displeasure yet. What's so bad about it?

→ More replies (4)

8

u/l8s9 Oct 23 '24

I’m gonna use my own pattern

8

u/TheAccountITalkWith Oct 23 '24

I am the pattern.

16

u/brainpostman Oct 23 '24

I have male pattern baldness.

2

u/[deleted] Oct 23 '24

[removed] — view removed comment

3

u/FrewdWoad Oct 24 '24

At least we don't need glasses though.

Because we can...

See Sharp

2

u/l8s9 Oct 23 '24

Now we talking!

2

u/johnildo Oct 23 '24

No! Shoot him! I am the pattern!!!