Q.How LINQ is beneficial than Stored Procedures?
Answer: There are couple of advantage of LINQ over stored procedures.
1. Debugging - It is really very hard to debug the Stored procedure but as LINQ is part of .NET, you can use visual studio's debugger to debug the queries.
2. Deployment - With stored procedures, we need to provide an additional script for stored procedures but with LINQ everything gets complied into single DLL hence deployment becomes easy.
3. Type Safety - LINQ is type safe, so queries errors are type checked at compile time. It is really good to encounter an error when compiling rather than runtime exception!
Q.Why Select clause comes after from clause in LINQ?
Answer: The reason is, LINQ is used with C# or other programming languages, which requires all the variables to be declared first. From clause of LINQ query just defines the range or conditions to select records. So that’s why from clause must appear before Select in LINQ.
Q.What is the benefit of using LINQ on Dataset?
Answer: The main aim of using LINQ to Dataset is to run strongly typed queries on Dataset.
Suppose we want to combine the results from two Datasets, or we want to take a distinct value from the Dataset, then it is advisable to use LINQ.
Normally you can use the SQL queries to run on the database to populate the Dataset, but you are not able to use SQL query on a Dataset to retrieve a particular values. To get this you need to use ADO.NET functionalities. But, in case of LINQ, it provides more dignified way of querying the Dataset and provides some new features as compared to ADO.NET.
Contributed by: Pinky Bhadran
Q) How can we find Sequence of Items in two different array (same Type) in the same order using linq query?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int[] numbersCopy = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Console.WriteLine(numbers.SequenceEqual(numbersCopy));
Output Result: True
Reference:
http://www.indiabix.com/technical/dotnet/language-integrated-query-linq/
http://www.careerride.com/linq-sequence-of-items.aspx
contributed by: Nithya S. Nair
Q.What are the three main components of LINQ or Language INtegrated Query?
Answer:
1. Standard Query Operators
2. Language Extensions
3. LINQ Providers
Reference:
http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-2.html
http://linqfaqs.blogspot.com/2011/08/what-are-three-main-components-of-linq.html
Q.How are Standard Query Operators implemented in LINQ?
Answer: Standard Query Operators are implemented as extension methods in .NET Framework. These Standard Query Operators can be used to work with any collection of objects that implements the IEnumerable interface. A class that inherits from the IEnumerable interface must provide an enumerator for iterating over a collection of a specific type. All arrays implement IEnumerable. Also, most of the generic collection classes implement IEnumerable interface.
Reference:
http://linqsqo.codeplex.com/
http://bartdesmet.net/blogs/bart/archive/2006/07/04/4115.aspx
Q.How are Standard Query Operators useful in LINQ?
Answer: Standard Query Operators in LINQ can be used for working with collections for any of the following and more.
1. Get total count of elements in a collection.
2. Order the results of a collection.
3. Grouping.
4. Computing average.
5. Joining two collections based on matching keys.
6. Filter the results
Reference:
http://odetocode.com/Articles/739.aspx
http://www.4guysfromrolla.com/articles/040109-1.aspx
Q. List the important language extensions made in C# to make LINQ a reality?
Answer:
1. Implicitly Typed Variables
2. Anonymous Types
3. Object Initializers
4. Lambda Expressions
contributed by: Saravana Kumar
Click here to got to index of .net interview questions
Answer: There are couple of advantage of LINQ over stored procedures.
1. Debugging - It is really very hard to debug the Stored procedure but as LINQ is part of .NET, you can use visual studio's debugger to debug the queries.
2. Deployment - With stored procedures, we need to provide an additional script for stored procedures but with LINQ everything gets complied into single DLL hence deployment becomes easy.
3. Type Safety - LINQ is type safe, so queries errors are type checked at compile time. It is really good to encounter an error when compiling rather than runtime exception!
Q.Why Select clause comes after from clause in LINQ?
Answer: The reason is, LINQ is used with C# or other programming languages, which requires all the variables to be declared first. From clause of LINQ query just defines the range or conditions to select records. So that’s why from clause must appear before Select in LINQ.
Q.What is the benefit of using LINQ on Dataset?
Answer: The main aim of using LINQ to Dataset is to run strongly typed queries on Dataset.
Suppose we want to combine the results from two Datasets, or we want to take a distinct value from the Dataset, then it is advisable to use LINQ.
Normally you can use the SQL queries to run on the database to populate the Dataset, but you are not able to use SQL query on a Dataset to retrieve a particular values. To get this you need to use ADO.NET functionalities. But, in case of LINQ, it provides more dignified way of querying the Dataset and provides some new features as compared to ADO.NET.
Contributed by: Pinky Bhadran
Q) How can we find Sequence of Items in two different array (same Type) in the same order using linq query?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int[] numbersCopy = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Console.WriteLine(numbers.SequenceEqual(numbersCopy));
Output Result: True
Reference:
http://www.indiabix.com/technical/dotnet/language-integrated-query-linq/
http://www.careerride.com/linq-sequence-of-items.aspx
contributed by: Nithya S. Nair
Q.What are the three main components of LINQ or Language INtegrated Query?
Answer:
1. Standard Query Operators
2. Language Extensions
3. LINQ Providers
Reference:
http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-2.html
http://linqfaqs.blogspot.com/2011/08/what-are-three-main-components-of-linq.html
Q.How are Standard Query Operators implemented in LINQ?
Answer: Standard Query Operators are implemented as extension methods in .NET Framework. These Standard Query Operators can be used to work with any collection of objects that implements the IEnumerable interface. A class that inherits from the IEnumerable interface must provide an enumerator for iterating over a collection of a specific type. All arrays implement IEnumerable. Also, most of the generic collection classes implement IEnumerable interface.
Reference:
http://linqsqo.codeplex.com/
http://bartdesmet.net/blogs/bart/archive/2006/07/04/4115.aspx
Q.How are Standard Query Operators useful in LINQ?
Answer: Standard Query Operators in LINQ can be used for working with collections for any of the following and more.
1. Get total count of elements in a collection.
2. Order the results of a collection.
3. Grouping.
4. Computing average.
5. Joining two collections based on matching keys.
6. Filter the results
Reference:
http://odetocode.com/Articles/739.aspx
http://www.4guysfromrolla.com/articles/040109-1.aspx
Q. List the important language extensions made in C# to make LINQ a reality?
Answer:
1. Implicitly Typed Variables
2. Anonymous Types
3. Object Initializers
4. Lambda Expressions
contributed by: Saravana Kumar
Click here to got to index of .net interview questions
No comments:
Post a Comment