Support us MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe C# Videos C# Programs Buy DVD

LINQ Interview Questions Part 2



What are the three main components of LINQ or Language INtegrated Query?
1. Standard Query Operators
2. Language Extensions
3. LINQ Providers

How are Standard Query Operators implemented in LINQ?
Standard Query Operators are implemented as extension methods in .NET Framework. These Standard Query Operators can be used to work with any collection of objects that implements the IEnumerable interface. A class that inherits from the IEnumerable interface must provide an enumerator for iterating over a collection of a specific type. All arrays implement IEnumerable. Also, most of the generic collection classes implement IEnumerable interface.

How are Standard Query Operators useful in LINQ?
Standard Query Operators in LINQ can be used for working with collections for any of the following and more.
1. Get total count of elements in a collection.
2. Order the results of a collection.
3. Grouping.
4. Computing average.
5. Joining two collections based on matching keys.
6. Filter the results


List the important language extensions made in C# to make LINQ a reality?
1. Implicitly Typed Variables
2. Anonymous Types
3. Object Initializers
4. Lambda Expressions



What is the purpose of LINQ Providers in LINQ?
LINQ Providers are a set of classes that takes a LINQ query and dynamically generates a method that executes an equivalent query against a specific data source.


What are the four LINQ Providers that .NET Framework ships?
1. LINQ to Objects - Executes a LINQ query against a collection of objects
2. LINQ to XML - Executes an XPATH query against XML documents
3. LINQ to SQL - Executes LINQ queries against Microsoft SQL Server.
4. LINQ to DataSets - Executes LINQ queries against ADO.NET DataSets.


Write a program using LINQ to find the sum of first 5 prime numbers?

7 comments:

  1. I went for an interview and I faced the same questions which you mentioned here, but I could answer only few of them. Well thanks for sharing such knowledgeable post. I save this and will be prepare for next one interview.

    ReplyDelete
  2. when to prefer Linq and when to prefer stored procedure?

    ReplyDelete
  3. when should i use temp table ?
    when should i use table variable?
    when should i use CTE?
    when should i use Derived Tables?

    ReplyDelete
  4. Thanks a lot for giving such a nice explanations for most wanted questions

    ReplyDelete
  5. 3. LINQ to SQL - Executes LINQ queries against Microsoft SQL Server.

    it does not executes they query but it translates the QUERY to T-SQL format and then ADO provider executes it.

    ReplyDelete
  6. Does Linq is faster than ADO.NET ? Performance criteria while using Linq?

    ReplyDelete

If you are aware of any other asp.net questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us