1. What is LINQ
in c#? Why LINQ is required?
LINQ or language integrated query is the collection of
standard query operators which provides query facility in .net framework
language like c#, vb.net.
LINQ acts as bridge between real world of data and world of
objects.
2. What are the
types of LINQ?
- LINQ to objects
- LINQ to xml
- LINQ to dataset
- LINQ to LINQ
- LINQ to entity
3. Why LINQ is
useful than stored procedure?
Debugging: - We can debug LINQ because it the part of .net.
Visual studio debugger can be used to debug LINQ. But we cannot debug stored
procedure.
Deployment: - for stored procedure, additional script is
required but for LINQ everything get compiled into single DLL hence deployment
becomes easy.
Type Safety: - LINQ is type safe, so query will give error
at compile time.
4. What are
main components of LINQ? Explain what is the extension of file when LINQ to Sql
is used?
The main components of LINQ are
- Standard Query Operator
- Language Extension
- LINQ Provider
Extension of file used in LINQ to sql is .dbml.
5. Define what
is Where clause and Let clause?
Where clause: - Allows adding some conditional filters to
LINQ query.
Let clause: - It allows defining variable and assigning it a
value calculated from the data value.
6.
Why SELECT clause comes after FROM clause in LINQ?
With other programming languages and c#, it requires
declaring all variables first. “FROM” clause of LINQ query define the range or
condition to select records. So FROM clause must appear before SELECT clause.
7. What is
lambda expression in LINQ?
A lambda expression is an anonymous function that you can
use to create delegate or expression tree types. By using lambda expressions,
you can write local functions that can be passed as arguments or return as the
value of function call. Lambda expressions are particularly helpful for writing
LINQ query expression.
Example: -
Lambda expression x=> x*x specifies a parameter that’s
named x and return the value of x squared.
8. Different
between Skip and Skipwhile in LINQ?
- Skip: - It is taking integer argument and from the given IEnumerable it skip the top n numbers.
- Skipwhile: - It will continue to skip the element as far as the input condition is true. It will return all the remaining element if the condition is false.
9. what is the
role of DataContext classes in LINQ?
DataContext acts as a bridge between Sql Server Database and
LINQ to Sql. For accessing the data from database and changing data from
database , it conatains connection string and function.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.