LINQ Interview Questions and Answers Part 3

By
1.) What are Standard Query operators in LINQ ?                                                             
The standard query operators are the methods that form the LINQ pattern.These operators provide query capabilities including filtering ,projection,aggregation and sorting.The standard query operator in LINQ is an application programming interface (API) that enables querying of any .NET array or collection.
There are two set of standard query operators in LINQ.
  1. Operator on objects of the type IEnumerables <T>
  2. Operator on objects of the type IQueryable <T>
2.) What are the List of Standard Query operators in LINQ ?                                       
  • Filtering operator
  • Projection operator
  • Sorting Operator
  • Join Operator
  • Grouping operator
  • Quantifier Operator
  • Partitioning operator
  • Set operator
  • Element operator
  • Aggregate operator
  • Conversion operator
  • Generation operator
3.) What is filtering operators in LINQ ?                                                                            
Filtering operators contains only those element that satisfy a specified given condition. 'WHERE' Clause in C# or VB is used as filtering operator in LINQ.
Syntax:-
public static IEnumerable<T> WHERE<T>
   (this IEnumerable<T> source, 
    Function<T, bool> predicate);

More Details...
4.) What is projection operators in LINQ ?                                                                           
The projection operators are used to transform an object of a different type.We can Construct a new object of a different type that built from each object by using projection operators.
Syntax:-
public static IEnumerable<S>select/selectmany<T,S>
   (this IEnumerable<T> source, 
    Function<T,S> selector);

More Details...
5.) What methods are used in projection operators ?                                                     
  • Select()
  • Selectmany()
6.) What is sorting operators in LINQ?                                                                                  
The sorting operator in LINQ arranges the elements of a sequence based on one or more attributes.It changes the order of elements of sequence returned by the query.
 Syntax:-
public static orderedsequence<T>orderBy/orderByDescending<T,S>
   (this IEnumerable<T> source, 
    Function<T,S> keyselector);

More Details...
7.) What clauses are used in sorting operators ?                                                                
  • OrderBy
  • orderbydescending
  • orderbyascending
8.) What is Join operators in LINQ ?                                                                                     
The Join operators in LINQ are used to join object in one data source with objects that share a common attribute in another datasource.
Syntax:-
public static IEnumerable<V>Join<T,U,S,V>
   (this IEnumerable<T> outer, 
        IEnumerable<U> inner,
    Function<T,S> outerKeyselector,
    Function<U,S> innerKeyselector,
    Function<T,U,V> resultselector);

More Details...
9.) What is  LINQPad ?                                                                                                                 
LINQPad is a popular tool for testing LINQ Queries.It allows you to execute LINQ queries ,c#,vb, sql statement etc.This is developed by Joseph Albahari.

10.) What is Grouping Operator in LINQ ?                                                                            
Grouping operator is used to put data into groups so that the elements in each group share a common attribute. 
Syntax:-
public static IEnumerable<IGrouping <T,S>>GroupBy<S,T>
   (Me IEnumerable<S> source, 
    Function<S,T> KeySelector);

More Details...

0 comments:

Post a comment

Powered by Blogger.