Linq Query Interview Questions and Answers Part 1

By
1.) What is LINQ ?                                                                                                                            
LINQ stands for language Integrated query.It was introduced as a new component of .NET Framework 3.0 .Its syntax is similar to Structure Query Language (SQL).Linq is a programming model that is used to provide a consistent method to obtain and manipulate the data.It can  easily perform some query operations from various data sources like  SQL,XML,Web services ,Dataset etc.LINQ Query performs additional operations such as sorting ,ordering and grouping the retrieved data.

2.) Why does we use LINQ Query?                                                                                            
There are following reasons to use LINQ Query as given below:-
  • LINQ Provide full type checking at compile time.
  • LINQ is used with c# and vb .net in .NET Framework.
  • LINQ Provides uniform programming models (use common query for different data sources).
3.) What are the various data sources used with LINQ?                                                  
  • LINQ to Object
  • LINQ to ADO.NET
  • LINQ to XML
4.) Which Namespace is used for LINQ?                                                                               
Using System.LINQ.

5.) What are the advantage of  LINQ?                                                                                     
There are some advantages of LINQ Query.
  • LINQ Provides uniform programming model(use common query for different data sources )
  • LINQ supports some powerful features like ordering ,filtering and grouping.
  • It provides short codes.
  • Linq query can be used again and again.
  • LINQ helps to avoid Runtime errors.
  • LINQ query  uses .NET Developers for Debugging purpose.
6.) What are the disadvantage of  LINQ?                                                                               
There are some disadvantage of LINQ.
  • It is more complex than SQL query.
  • Sql query is good for writing the complex query.
  • LINQ query performance is not good as sql query.
  • We can't implement some features with linq like sql(cached feature of Stored procedure in sql).
  7.) What are three basic steps to execute the LINQ query?                                           
  1. Obtain the data source that can be either sql database or an XML File.
  2. Create the query
  3. Execute the Linq query
  8.) What is Extension Methods in LINQ query?                                                                
The Extension Method, in .NET Framework allow you to add methods to existing types without creating a new derived type.Means You can easily extend the functionality of existing method.This is done by re-compiling and modifying the original type.
         The extension Method takes parameters in which first parameter defines the types that it extends.A class that defines the Linq extension method is called Enumerable class. 
More Details...
  9.) What are the rules for extension methods?                                                                 

  • Method must be static 
  • Method must be declared in static class.
  • Method must be taken the parameter
  10.) What is difference between Extension method and Normal Method?             
  • In an Extension Method requires this keyword with the first parameter but in Normal method don't like that.
  • The Extension Method can not access the private members of the type that it extends.

0 comments:

Post a comment

Powered by Blogger.