Language Integrated Query (LINQ) Interview Questions and Answers

LINQ Questions and Answers:

1 :: What is Quantifiers in reference linq to Dataset?

Quantifier Operators return the Boolean value (either True or false) if some or all the elements in a sequence satisfy a condition,
Mainly two Quantifiers in linq:

Any
All

Examples (vb)

"Any" to determine if any of the words in the array contain the substring

Public Sub ExampleAny()
Dim words() = {"believe", "relief", "receipt", "field"}
Dim iAfterE = words.Any(Function(w) w.Contains("ei"))
Console.WriteLine("There is a word that contains in the
list that contains 'ei': {0}", iAfterE)
End Sub


Result:
There is a word that contains in the list that contains 'ei': True

"All" to return a grouped a list of products only for categories that have all of their products in stock

Public Sub Quantifier_All_Exam()
Dim products = GetProductList()
Dim productGroups = From p In products _
Group p By p.Category Into Group _
Where (Group.All(Function(p) p.UnitsInStock > 0)) _
Select Category, ProductGroup = Group
ObjectDumper.Write(productGroups, 1)
End Sub
0/5 Rating (0 vote)
Is This Answer Correct?    1 Yes 0 No
Place Your Answer

2 :: Why do we use “Contains” method for strings type functions?

Contains method Used to find all matching records From Given string using Matching keywords.
Example-
This Examples returns the Customer Names from Customer tables whose Names have contains “Anders”

Public void LinqToSqlStringUsingContains()
{
Var q = From c In db.Customers _
Where c.ContactName.Contains("Anders") _
Select c
ObjectDumper.Write(q)
}
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 1 No
Place Your Answer

3 :: List out the Data Context Functions. Where do we use “SubmitChanges()”?

Create Database ()
Delete database ()
Database Exist ()
Submit Changes ()
Create Query()
Log()
SubmitChanges() - SunbmitChanges Data Context Fuction Used to submit any update to the actual database.
0/5 Rating (0 vote)
Is This Answer Correct?    1 Yes 0 No
Place Your Answer

4 :: Differentiate between Conversion Operator “IEnumerable” and “ToDictionary” of LINQ?

IEnumerable and To Dictionary both are Conversion Operator which are used to solved to conversion type Problems.
“AsEnumerable ” operator simply returns the source sequence as an object of type IEnumerable. This kind of “conversion on the fly” makes it possible to call the general-purpose extension methods over source, even if its type has specific implementations of them
Signature:

public static IEnumerable<T> AsEnumerable<T>
(
this IEnumerable<T> source
);


“ToDictionary ” Conversion Operator is the instance of Dictionary (k,T) . The “keySelector ”predicate identifies the key of each item while “elementSelector ”, if provided, is used to extract each single item.
Key and elementSelector Predicate can be Used in following ways-
Example-

Public void ToDictionatyExample()
{
Var scoreRecords=
{
new {Name = "Alice",Score = 50 },
new {Name = "Bob",Score = 40 },
new {Name = "Cathy", Score = 45}
};
Var scoreRecordsDict = scoreRecords.ToDictionary(sr => sr.Name);
Console.WriteLine("Bob's score: {0}", scoreRecordsDict("Bob"));
}


Result: Bob's score: { Name = Bob, Score = 40 }
0/5 Rating (0 vote)
Is This Answer Correct?    1 Yes 0 No
Place Your Answer

5 :: How can we find Sequence of Items in two different array (same Type) in the same order using linq query?

Public void MatchSequenceLinq()
{
Var wordsA = {"Rahul","ashok","sweta"};
Var wordsB = {"rahul","ashok","sweta"};
var match = wordsA.SequenceEqual(wordsB);
Console.WriteLine("The sequences match: {0}", match);
}
0/5 Rating (0 vote)
Is This Answer Correct?    1 Yes 0 No
Place Your Answer

Rate This Category:
3/5 Rating (2 votes)
Place Your Question



Top: Language Integrated Query (LINQ) Interview Questions and Answers
Language Integrated Query (LINQ) Interview Questions and Answers

Top Frequently Asked LINQ Question
Frequently Asked LINQ Job Interview Question


Top Frequently opened Applications Programs Job Interview categories
Most popular Applications Programs Job Interview categories

Comments About Language Integrated Query (LINQ) Interview Questions and Answers

Share your valuable opinions, ideas and suggestions about Language Integrated Query (LINQ) Interview Questions and Answers
While placing your comment your email address is required but won't be published any where else; Personal information will be kept confidential; we do not sell or release our respective visitors private information.
  1. Webmaster 22nd of May 2012

    Webmaster Said

    Tell us what you feel about Language Integrated Query (LINQ) Interview Questions and Answers
    All comments will be published after review. No login or registration is required to post a comment on Language Integrated Query (LINQ) Interview Questions and Answers We offer and invite you to submit your valuable comment now; Please be respectful of others when commenting. Insulting others, self-promotional comments, website promotional comments, marketing stuff, SEO Techniques, SMS-style content and off-topic comments will not be approved at this information portal.
    So start sharing your thoughts regarding Language Integrated Query (LINQ) Interview Questions and Answers
    Thank you.

Leave a Comment

Leave a Comment
  1.  Enter This Verification Code  Regenerate Verification Code  



Your reply will be added to the comment above (Below any other replies to this comment) -

Top Comments About: Language Integrated Query (LINQ) Interview Questions and Answers
Comments on Language Integrated Query (LINQ) Interview Questions and Answers

 
Top of Link batk to Language Integrated Query (LINQ) Interview Questions and Answers
Link batk to Language Integrated Query (LINQ) Interview Questions and Answers