Monday 14 November 2011

LINQ Interview Questions And Answers

Here, some common LINQ interview questions which asked by the interviewer.  
 

What is use of ‘Distinct’ in a LINQ ?

It removes duplicate values from result set.

What is different between LINQ and Stored Procedure?

  •  We can debug LINQ as it is part of .Net, whereas Stored procedure can’t be.
  •  Deployment is easy with LINQ as everything compiled into DLL whereas with Stored procedure script is required for deployment.
  •  At compile time we can find error, if any in LINQ but it not possible with Stored procedure.
What is role of DataContext classes in LINQ?
  
DataContext  acts as a bridge between a  SQL Server database and the LINQ to SQL. It contains the connection string  and functions for accessing the database and for also  changing  the data in the database.   

In LINQ, ‘Select’ comes after ‘ From’, why?

In any programming language, variable defines first then conditions specifies. In LINQ also, all variables declared first by using ‘Select’ clause then ‘From’ clause is used for define conditions.

What is the extension of LINQ to SQL file ?

It is .dbml.

Disadvantage of LINQ over Stored procedure?

Stored procedure compiles one time and executed every time whereas LINQ compiled everytime , so Stored Procedure is faster as compare to LINQ.


No comments:

Post a Comment