14 November 2013


1.      Difference between First vs FirstOrDefault in LINQ
  •    First: Gives first record from the collection, if collection doesn't have any object then throws error.
  • FirstOrDefault: FirstOrDefault extension method is used to retrieve the first element from the collection, if not then gives null.
2.      Difference between Last vs LastOrDefault in LINQ?
  • Last:Last extension method gives last element from the collection. If there is no element in the collection, it throws error.
  • LastOrDefault:LastOrDefault extension method gives the last element form the collection, if not gives null.
3.     When will we use ThenBy in LINQ?
               ThenBy is used with OrderBy or OrderByDescending. It is used to apply sorting on already sorted collection using OrderBy or OrderByDescending.
4.     Where to Use SequenceEqual ?
                   SequenceEqual extension method is used to determine if both collections sequence are equal.
5.     what is mean by SkipWhile?
            SkipWhile extension method is used to skip the elements that satisfies the given filter criteria till it doens't get any element that doesn't satisfy.
6.     How to use Take Method in LINQ?
          Take extension method is used to take specified number of elements from the collection.
7.     What is mean by Lambda expression?
  • A lambda expression is an function that contain many expressions and statements.
  • Lambda expression used to create delegates or expression tree types.
  • All lambda expressions use the lambda operator =>, which is read as "goes to".
  • The left side of the lambda operator specifies the input parameters.
  • The right side holds the expression or statement block.

8.     What is ORM?
         ORM stands for Object-Relational Mapping. Sometimes it is called O/RM, or O/R mapping. It is a programming technique that contains a set of classes that map relational database entities to objects in a specific programming language.
9.     What is ODBC?
        ODBC (Open Database Connectivity) was developed to unify all of the communication protocols for various RDBMSs. ODBC was designed to be independent of programming languages, database systems, and Operating Systems. So with ODBC, an application could communicate with different RDBMSs by using the same code, simply by replacing the underlying ODBC drivers.
10. What is LINQ To SQL?
  •  LINQ to SQL is a component of the .NET Framework version 3.5 that provides a run-time infrastructure for managing relational data as objects.
  • LINQ to SQL fully supports transactions, views, Stored Procedures, and user-defined functions. It also provides an easy way to integrate data validation and business logic rules into your data model, and supports single table inheritance in the object model.
  • LINQ to SQL, ADO.NET SqlClient adapters are used to communicate with real SQL Server databases.
11. Difference between LINQ To SQL and LINQ To Object?
·        LINQ to SQL needs a Data Context object. The Data Context object is the bridge between LINQ and the database. LINQ to Objects doesn’t need any intermediate LINQ provider or API.
·        LINQ to SQL returns data of type IQueryable<T> while LINQ to Objects returns data of type IEnumerable<T>.
·        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.
·        LINQ to SQL is translated to SQL calls and executed on the specified database while LINQ to Objects is executed in the local machine memory.

12. What is mean by Entity Framework?
·        ADO.NET Entity Framework (EF) was first released with Visual Studio 2008 and .NET Framework 3.5 Service Pack 1. So far, many people view EF as just another ORM product from Microsoft, though by design it is supposed to be much more powerful than just an ORM tool.
·        The conceptual data model schema is expressed in the Conceptual Schema Definition Language (CSDL), the actual storage model is expressed in the Storage Schema Definition Language (SSDL), and the mapping in between is expressed in the Mapping Schema Language (MSL).

13. Difference between LINQ To SQL and LINQ To Entities?
·        LINQ to Entities applications work against a conceptual data model (EDM). All mappings between the languages and the databases go through the new EntityClient mapping provider. The application no longer connects directly to a database or sees any database-specific construct; the entire application operates in terms of the higher-level EDM model.

14. What are all the Operator Type  in LINQ To Object?

·        Aggregation Aggregate, Average, Count, LongCount, Max, Min, Sum
·        Conversion Cast, OfType, ToArray, ToDictionary, ToList, ToLookup, ToSequence
·        Element DefaultIfEmpty, ElementAt, ElementAtOrDefault, First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault
·        Equality EqualAll
·        Generation Empty, Range, Repeat
·        Grouping GroupBy
·        Joining GroupJoin, Join
·        Ordering OrderBy, ThenBy, OrderByDescending, ThenByDescending, Reverse
·        Partitioning Skip, SkipWhile, Take, TakeWhile
·        Quantifiers All, Any, Contains
·        Restriction Where
·        Selection Select, SelectMany
·        Set Concat, Distinct, Except, Intersect, Union

No comments: