468,321 Members | 1,830 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

ADO.NET or LINQ to SQL

Learning C# and SQL Server. Just wondered what are the pros and cons of
either approach to using SQL Server databases.

(It may be 'how long is a piece of string'!)

Thanks
Sep 3 '08 #1
2 1448

"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
Learning C# and SQL Server. Just wondered what are the pros and cons of
either approach to using SQL Server databases.
To begin with, ADO.NET is the underlying technology for LINQ to SQL (and
Entity Framework), so it's not an either-or choice. If you use LINQ to SQL
or EF, you're still using ADO.NET, even if indirectly.

As to what it is - it's fairly simple. ADO.NET by itself is a rather
traditional API to work with SQL databases. It provides some straightforward
low-level abstractions such as DB connection, DB transactions, SQL command,
and a forward-only cursor to read query result. Otherwise, it does not
attempt to abstract away the relational data model or the SQL dialect used
by the specific database you're working with. You work directly with SQL
commands using syntax and semantics of the database you work against,
passing them as strings, and they are typically delegated straight to the
database server unmodified. Because of this, you can use ADO.NET to work
with virtually any database (well, so long as it has an ADO.NET or OLE DB
driver...), but it's hard to be compatible with multiple databases -
advanced SQL often becomes unportable quickly.

LINQ to SQL attempts to abstract away the SQL part by replacing it with LINQ
queries. To do so, it also dresses tables up as classes, and table records
as instances of those classes (but it doesn't go all the way full-fledged
ORMs usually do). It only works with SQL Server, though, and, apparently,
there are no plans to change that (now that Entity Framework is the next big
thing). But within its limitations, it's still okay - you get the
convenience of LINQ and static typing for your data, and you don't really
lose anything.
Sep 4 '08 #2
Pavel: thank you. You have encapsulated the key features excellently.

"Pavel Minaev" wrote:
>
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
Learning C# and SQL Server. Just wondered what are the pros and cons of
either approach to using SQL Server databases.

To begin with, ADO.NET is the underlying technology for LINQ to SQL (and
Entity Framework), so it's not an either-or choice. If you use LINQ to SQL
or EF, you're still using ADO.NET, even if indirectly.

As to what it is - it's fairly simple. ADO.NET by itself is a rather
traditional API to work with SQL databases. It provides some straightforward
low-level abstractions such as DB connection, DB transactions, SQL command,
and a forward-only cursor to read query result. Otherwise, it does not
attempt to abstract away the relational data model or the SQL dialect used
by the specific database you're working with. You work directly with SQL
commands using syntax and semantics of the database you work against,
passing them as strings, and they are typically delegated straight to the
database server unmodified. Because of this, you can use ADO.NET to work
with virtually any database (well, so long as it has an ADO.NET or OLE DB
driver...), but it's hard to be compatible with multiple databases -
advanced SQL often becomes unportable quickly.

LINQ to SQL attempts to abstract away the SQL part by replacing it with LINQ
queries. To do so, it also dresses tables up as classes, and table records
as instances of those classes (but it doesn't go all the way full-fledged
ORMs usually do). It only works with SQL Server, though, and, apparently,
there are no plans to change that (now that Entity Framework is the next big
thing). But within its limitations, it's still okay - you get the
convenience of LINQ and static typing for your data, and you don't really
lose anything.
Sep 5 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dave Johnson | last post: by
9 posts views Thread by =?Utf-8?B?cmF1bGF2aQ==?= | last post: by
reply views Thread by =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post: by
4 posts views Thread by =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post: by
14 posts views Thread by thj | last post: by
9 posts views Thread by Cirene | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post: by
4 posts views Thread by George | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.