7.25.2012

LINQ Difference FAQs-1

1.Difference between LINQ and SQL
S.No LINQ SQL
1 LINQ Stands for language integrated query. SQL stands for Structured Query Language.
2 LINQ Statements are verified during compile time. SQL statements can be used in a application gets verified for their syntaxes  only in the run time.
3 To use LINQ we can depend upon our .Net Language syntaxes and also we can consume base class library functionalities. To use SQL we need to be familiar with SQL syntaxes and also the pre-defined functions of SQL like MAX,MIN,LEN and SUBSTRING  etc...
4 LINQ Statements can be debugged as they execute under framework environment.
SQL .
As SQL statements execute on Database server debugging of the code is not possible.

2.Difference between LINQ to SQL and Entity Framework
S.No LINQ to SQL Entity Framework
1 It only works with Sql server. It works with variety of db products.
2 Used for rapid application development. Cannot used for rapid application development.
3 It does not support for complex type. It provides support for complex type.
4 It cannot generate db from model. It can generate db from model.
5 Mapping type ( class to single table) Mapping type ( class to multiple tables)
6 We can query data using DataContext. We can query data using esql,object services,entity client and linq to entities.


Another Good Reference:


(OR)



3.Difference between LINQ and Stored Procedures



S.No LINQ Stored Procedures
1 As LINQ is part of .NET, we can use visual studio’s debugger to debug the queries It is really very hard to debug the Stored Procedure
2 With LINQ everything gets complied into single DLL hence deployment becomes easy. With Stored Procedures, we need to provide an additional script for deployment
3 LINQ is type safe, so queries errors are type checked at compile time.It is really good to encounter an error when compiling rather than runtime exception! Stored Procedures are not type safe i.e., error can be caught only during runtime.
4 LINQ supports multiple databases With Stored Procedures which need to be re-written for different databases.
5 LINQ supports abstraction which allows framework to add additional improvements like multi threading. It is much simpler and easier to add this support through LINQ than Stored Procedures. As Stored Procedures does not support abstaction , so it is difficult to add additional impovements like multi threading
6 LINQ queries need to compile before execution.Therefore, LINQ is slower than Stored Procedures. Stored Procedures are ster thn LINQ because they are precompiled i.e., Stored Procedures have a predictable execution plan.Therefore, if a stored procedure is being executed for the second time, the database gets the cached execution plan to execute the stored procedure.

4.Difference between LINQ to SQL and LINQ to Objects



S.No LINQ to SQL LINQ to Objects
1 LINQ to SQL needs a Data Context object. The Data Context object is the bridge between LINQ and the database. LINQ to Objects does not need any intermediate LINQ provider or API.
2 LINQ to SQL returns data of type IQueryable LINQ to Objects returns data of type IEnumerable.
3 LINQ to SQL is translated to SQL by way of Expression Trees, which allow them to be evaluated as a single unit and translated to the appropriate and optimal SQL statements. LINQ to Objects does not need to be translated.
4 LINQ to SQL is translated to SQL calls and executed on the specified database LINQ to Objects is executed in the local machine memory.

5.Difference between LINQ to SQL and LINQ to Entities


S.No LINQ to SQL LINQ to Entities
1 Does not support Conceptual Data Model Supports Conceptual Data Model
2 Does not support Storage Schema Supports Storage Schema
3 Does not support Mapping Schema Supports Mapping Schema
4 Does not support New Data Access Provider Supports New Data Access Provider
5 Does not support Non-SQL Server Database Support Supports Non-SQL Server Database Support
6 Supports Direct Database Connection Does not support Direct Database Connection
7 Does not support Multiple-table Inheritance Supports Multiple-table Inheritance
8 Does not support Single Entity from Multiple Tables Supports Single Entity from Multiple Tables

2 comments:

  1. Great article and blog, I found some useful information on it and willing to see more from you.

    Hire C# Developers | .NET Development Company

    ReplyDelete
  2. Thanks!! Sure ! I will include more difference between questions & answers

    ReplyDelete