3.Difference between LINQ and Stored Procedures
1As LINQ is part of .NET, wecan use visual studio’sdebugger to debug the queriesIt is really very hard to debug theStored Procedure2With LINQ everything getscomplied into single DLL hencedeployment becomes easy.With Stored Procedures, we needto provide an additional script for deployment3LINQ is type safe, so querieserrors are type checked atcompile time.It is really good toencounter an error whencompiling rather than runtimeexception!Stored Procedures are not typesafe i.e., error can be caught onlyduring runtime.4LINQ supports multipledatabasesWith Stored Procedures whichneed to be re-written for differentdatabases.5LINQ supports abstractionwhich allows framework to addadditional improvements likemulti threading. It is muchsimpler and easier to add thissupport through LINQ thanStored Procedures. As Stored Procedures does notsupport abstaction , so it is difficultto add additional impovements likemulti threading6LINQ queries need to compilebefore execution.Therefore,LINQ is slower than StoredProcedures.Stored Procedures are ster thnLINQ because they areprecompiled i.e., StoredProcedures have a predictableexecution plan.Therefore, if astored procedure is being executedfor the second time, the databasegets the cached execution plan toexecute the stored procedure.
4.Difference between LINQ to SQL and LINQ to ObjectsS.NoLINQ to SQLLINQ to Objects
1LINQ to SQL needs a DataContext object. The DataContext object is the bridgeLINQ to Objects does not need anyintermediate LINQ provider or API.