LINQ interview questions part-II

13. Which interface implements the standard query operators in LINQ?
The standard query operators implement the IEnumerable<T> or the IQueryable<T> interface in C# and the IEnumerable(Of T) or the IQueryable(Of T) interface in Visual Basic.


14. What are standard query operators in LINQ?
The standard query operators in LINQ are the extension methods that form the LINQ pattern. These operators form an API that enables querying of any .NET array or collection. It operates on sequences and allows you to perform operations, such as determining if a value exists in the sequence and performing an aggregated function, such as a summation over a sequence.


15. On what parameter does the GroupBy clause group the data?
The GroupBy clause groups the elements that share a common attribute.


16. What is a LinqDataSource control?
The LinqDataSource control enables you to use LINQ. in an ASP.NET Web page by setting the properties in the markup text. You can use the control retrieve or modify data. It is similar to the SqIDataSource and ObjectDataSource controls in the sense that it can be used to declaratively bind other ASP.NET controls on a page to a data source. The difference is that instead of binding directly to a database or to a generic class, the LinqDataSource control is designed to bind a LINQ enabled data model.


17. How can you open the O/R Designer?
You can open the O/R Designer by adding a new LINQ to SQL Classes item to a project.


18. The standard query operators are themselves a set of extension methods that provide the LINQ query functionality for any type that implements the IEnumerable<T> interface in Visual Basic. Is it True or False?
False, as it implements the IEnumerable(T) interface in Visual Basic and the IEnumerable<T> interface is implemented in C#.


19. What are lambda expressions in LINQ?
A lambda expression is a function without a name that calculates and returns a single value. All lambda expressions use the lambda operator =>, which read as goes to. The left side of the lambda operator specifies the input parameters and the right side holds the expression or statement block.



20. Before you query a DataSet object by using LINQ to DataSet, you must first populate the dataset How can you do this?
You can load the data into the dataset by using different methods, such as:
  • Using the DataAdapter class
  • Using LINQ to SQL


21. What are the different implementations of LINQ?
The different implementations of LINQ are:
  • LINQ to SQL - Refers to a component of.NET Framework version 3.5 that provides a run-time infrastructure to manage relational data as objects.
  • LINQ to DataSet - Refers to a component that makes it easier and faster to query over data cached in a DataSet object.
  • LINQ to XML - Provides an in-memory XML programming interface.
  • LINQ to Objects - Refers to the use of LINQ queries with any IEnumerable or IEnumerable(T) collection directly, without the use of an intermediate LINQ provider or API, such as LINQ to SQL or LINQ to XML.



22. Which command-line tool generates code and mapping for the LINQ to SQL component of .NET Framework?
The SqlMetal.exe command-line tool generates code and map the LINQ to SQL component.


23. Name the control that exposes the LINQ features to Web developers through the ASP.NET data-source control architecture.

The LinqDataSource control exposes the LINQ features to Web developers through the ASP.NET data-source control architecture.


24. What is the difference between the Select clause and SelectMany() method in LINQ?

Both the Select clause and SelectMany() method are used to produce a result value from a source of values. The difference lies in the result set. The Select clause is used to produce one result value for every source value. The result value is a collection that has the same number of elements from the query. In contrast, the SelectMany() method produces a single result that contains a concatenated collection from the query.

No comments:

Post a Comment