Ans: LINQ stands for language integrated query. Its a part of .Net 3.5 framework.It provides quering capabilities in .Net languages.it intergrates databse model into programming model.logic can be used to retrieve data with sql like statements in C#.
Ans: Data providers allows us to query different data sources using LINQ.There are different data providers for different data sources such as:
LINQ providers converts the LINQ queries to the queries which specific data source understands.
Ans:
Ans: For constructing expression trees Expression Lambda is used but we cannot use Statement Lambda for this purpose. Further, statement lambda is not supported by expression providers like LINQ to SQL.
Ans: LINQ is divided into 3 categories --
a. linq to objects--this includes mainly quering collections which implemet IEnumerable interface.
b. linq to ADO.NET
c. linq to XML
Ans: Query expressions are used to write LINQ queries in similar way we write SQL queries.Below is a simple query expression:
IEnumerable<int> result = from item in listItmes
where item.name > "TV"
select item.price;
Ans: The above query finds the price of the product “TV”.
Ans: DataContext class can be explained as a bridge between a SQL Server database and the LINQ to SQL. It establishes connection to database for accessing the database. Communicate with database by submitting and retrieving objects and then change these objects to SQL queries. In a simpler way, it contains the connection string information, methods to connect to the database and manipulating the data in the database. With the help of data context, we can perform select, insert, update and delete operations over the data in the database.
Ans:
Ans:
Ans: Both XElement and XDocument are the classes defined by System.Xml.Linq namespace. XElement class represents an XML fragment. XDocument class represents an entire XML document with all associated meta-data. XDocument has a Declaration i.e. root whereas XElement is a single node.
int[] nums = new int[] {0,4,2,6,3,8,3,1};
var result = from n in nums
where n > 5
orderby n //orders in asc order
select n;
Ans: Lambda expression is like anonymous function.It does not not have a body and return type.It can assigned to a delegate.We use lambda expression in LINQ to assign it to a delegate.
It has the following form:
input arguments=>body
we can assign a lambda expression to a delegate which returns int as:
delegateMult del= x => x * x;
Ans: we can call above delegate as:del(10);
There are some aggregate operators used in Linq as given below:-
Ans: For loading everything under the top-level element, we have to use XElement.Load () and for loading any markup before the top-level element, we have to use XDocument.Load ().
Ans: it stands for object relational mapping wherein it provides the user with the ability to change and manipulate the objects without having to worry about how the objects are related to their datasource.
Ans:
Ans
Ans:
Ans: LINQ to DataSet is a very easy way to write query from the programming language instead of using a separate query languageI. It is useful to run queries on multiple datasets. Through SQL query, we are not able to retrieve a particular value from the dataset. LINQ is an efficient way to perform data manipulation operations (like searching, filtering, sorting) on Dataset.
Ans: System.Linq
Ans:
Ans: Extension methods allows us to add new methods to an existing type.When we use extension methods we add new methods without modifying the existing type.