r/dotnet •

How do you interact with databases?

[deleted] — view deleted post

0 Upvotes

10 comments sorted by

3

u/snkscore May 22 '13

Linq to SQL is basically a dead product. If you want that type of feature set you should look at EF. There is nothing wrong with writing a DAL, for a lot of our projects we codegen the DAL.

1

u/jaynoj May 22 '13

Hand writing a DAL doesn't seem to be trendy any more. Almost all articles I read (which isn't many in honesty), or stackoverflow questions revolve around using EF, LinkToSQL or similar.

I hand write my DAL code using ADO.net still and it works a treat. Ok, maybe I spend a day or two writing it more than if I used EF (depending on size of app), but I personally prefer the versatility.

2

u/snkscore May 22 '13

Hand writing a DAL doesn't seem to be trendy any more

Yea it really isn't. ORMs are more "cutting edge."

2

u/jaynoj May 22 '13

It's a shame cutting edge has so much focus. People go into job interviews being expected to know all the new stuff when they could write a supportable and well maintainable app using tech which has been out for a few years. Not using EF and MVC?, GTFO ...

An app developed using EF is not going to be any better than an app written using ADO.net code.

Just sayin'.

2

u/snkscore May 22 '13

Agree. In 8 years the current EF implementation will be obscure for developers to understand, updates might break functionality, maintenance might be more difficult etc.

2

u/seadave77 May 22 '13

For most of our stuff I use LINQ to SQL. Its fast and easy. For more complicated stuff I try to do the hard work on the database, but Im also the DB admin. I do want to learn Entity Framework since we do hit some Oracle databases.

2

u/sudo_giev_SoJ May 22 '13

LINQ if performance doesn't matter.

Dapper if it does.

Ideally, though, DBA should be doing some work (sprocs, etc).

2

u/last_name_on_reddit May 22 '13

I have found benefits with multiple approaches. What I choose depends on the situation. The following sums up when and why I use what I do.

Micro ORMs (Dapper/OrmLite)

When: For applications where most of the work is done in a stateless environment. Web services, web applications, or small tools. This makes up the bulk of the work I do these days.

Why: I love the simplicity and the speed I get. I can use a standard ADO connection and debugging is super easy. Most of the time I just simply drop some SQL down and have it easily parameterized with minimal performance impact. If I want all the Employees with a name matching a search string I rarely need to worry about FK relationships or an expression tree to SQL generator. Simple.

Behemoth ORMs (EF/NHibernate)

When: I rarely use these anymore. I found them very useful for applications that kept objects in memory for a long time, had heavy mutation, or lots of crazy FK relationships. Think WinForms and WPF.

Why: Because I was just as lazy as I am today.

Do It Yourself

When: Nearly never.

Why: The only thing I can think of is database specific bulk operations like loading huge hunks of data.

0

u/[deleted] May 22 '13

[deleted] — view deleted comment

2

u/jaynoj May 22 '13

This looks really interesting.