Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all just I want to know what's the benefit from using linq to sql ??

is it will be better to use linq to sql ot to use the classes for insert update delete and select ???


thanx in advance
Posted
Updated 15-May-12 10:22am
v2

Besides what Collin wrote see followings:
What you gain:
- You have a query language integrated in a .net language. Well, this is not new at all, but now in OOP.
- You have strongly typed datasets and strongly typed results, thus you have IntelliSense
- You have a layer above the db, thus you can separate data access, and change if needed
- You dont need to know SQL (theoretically)
- You dont need to deal with parameters, and thus you can (more or less) forget about SQLi
- Ease in development and maintenance
What you loose:
- The power of full control over your running query. As query optimizers are built for general cases, you might have special cases when you have to control even the query plan
- You loos the power of serverside user functions (UDF)
- You can actually forget what's in the DBMS aside from the data itself

But, it look like EntityFramework is the future. There you also have LINQ.

More generally: if you need deep control ower how statements are built and ran, don't use these features. But in most cases LINQ will be a good approach.
 
Share this answer
 
Comments
VJ Reddy 15-May-12 21:01pm    
Good points. 5!
It is not recomended actually.

In general for inserts updates deletes etc. you should use Stored Procedures. The reason being is that if the Table(s) change you then update the SPROC and there is no need to redistribute new code.


I have seen LINQ to SQL used for clean SPROC calls but really there is no need. It does allow for a quick code building etc. but it does not take that long to write the few lines needed to call SPROCs from code. There in lies the benefit though (the only benefit that I know of).
A simple GUI to access DBs (drag and drop what you need). If you are just testing and playing around trying to learn the technology it is quite useful. But for an actual system that will go live I would not recomend as the maintanence will kill you after any change requests come in.

In general LINQ to SQL has been considered dead for some time now.
 
Share this answer
 
v4
Comments
VJ Reddy 15-May-12 21:00pm    
Good points. 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900