Limey
Limey

Reputation: 2772

Linq To SQL: a newbies Journey

I am new to asp.net and I am trying to learn Linq to SQL. So I have found two different ways to pull from the database. The normal linq to SQL way and the direct SQL statement way.

I have both working, but I want to know which way is the accepted standard? I want to use straight SQL statements, because that is what I am use to, but I am trying to go with whatever is best practice.

Thanks

Upvotes: 2

Views: 135

Answers (5)

retrodrone
retrodrone

Reputation: 5920

Take a look at the selected answer to this popular question.

Entity Framework became the preferred way to interact with a SQL database in ~2008. Much of the heavy lifting in database calls and transactions is greatly simplified in EF.

If you continue to use Linq to SQL and want to learn from the master, have a look at Scott Guthrie's Post.

Upvotes: 3

Tod
Tod

Reputation: 8242

Personally, I much prefer using LINQ and have since the moment I learned it. You can turn on the log feature while you are learning and can see the SQL that gets created. If you have performance concerns and need to hand tweak SQL you can always revert to that. Just not having to hard code strings with table and field names makes code more maintainable and with intellisense also much more enjoyable to write.

Upvotes: 3

Justin Morgan
Justin Morgan

Reputation: 30715

There isn't really an accepted standard between straight SQL and LINQ (or any other ORM). It depends on what environment you're using it in, and what you want to do. However, Microsoft has announced that the LINQ to SQL project isn't going to be continued, so I suggest you consider the ADO.NET Entity Framework (which supports LINQ via LINQ to Entities) instead.

Upvotes: 1

Chad
Chad

Reputation: 1562

Entity Framework is to be Microsoft's best practice solution. Once you learn LINQ you will find it is much easier to code.

Upvotes: 3

Related Questions