Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADO.NET or Linq to SQL?

I am building a forum, and it has got 4 tables: Users, Threads, Comments, Topics.

I established the connection and the pages.. I started using the ADO.net way to insert data and select data..but then I found that to make more complex manipulations i need to know SQL. So I was looking for another way, and I found that I can open Visual Studio 2010, add Linq to SQL file that produced object relational designer. I read about how to write code, and I saw that I simply need to use a using statement with DataContext object with a simple code to update, add, delete rows in the tables.

I wanted to know, what are the advantages of using one way of querying over another?

like image 424
Dmitry Makovetskiyd Avatar asked Nov 17 '25 13:11

Dmitry Makovetskiyd


2 Answers

ADO.NET gives you low level control over your queries. If query speed is going to be of importance, this is where you want to be. If you speed is not very important, but rapid development and an Object Relational Model is, LINQ to SQL is a safe bet.

I would recommend Linq to SQL over ADO.NET though.

  1. Development is rapid and thinking in an ORM way is natural.
  2. If your queries are too slow, using the .ExecuteQuery method will allow you to pass in a sql statement that you have optimized as if you were doing it in the ADO.NET way. I have had much success with Linq to Sql.

Also I would look at Entity Framework. It gives you more control over your objects and how they are implemented, used and handled than Linq.

like image 150
Ryan Bennett Avatar answered Nov 19 '25 02:11

Ryan Bennett


LINQ to SQL is part of the ADO.NET family of technologies. It is based on services provided by the ADO.NET provider model. You can therefore mix LINQ to SQL code with existing ADO.NET applications and migrate current ADO.NET solutions to LINQ to SQL. The following illustration provides a high-level view of the relationship.

enter image description here


Refer to the following:

ADO.NET and LINQ to SQL

Advantages & Disadvantages of LINQ

Performance of LINQ to SQL over Normal Stored procedure

LINQ-to-SQL and Stored Procedures

like image 43
Akram Shahda Avatar answered Nov 19 '25 01:11

Akram Shahda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!