LINQ Interview Questions - 1 | Snaprecruit.com

LINQ Interview Questions - 1 | Snaprecruit.com

LINQ interview questions part 1

LINQ interview questions part 1

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. The full form of LINQ is _______.

Correct Answer is : Language-Integrated Query

2. LINQ supports ________ syntax.

Correct Answer is : C# and VB

3. Which of the following supports LINQ?

Correct Answer is : All of the above

4. A class must implement ____________ interface in order to provide querying facility using LINQ.

Correct Answer is : IEnumerable or IQueryable

5. Which of the following statement is TRUE?

Correct Answer is : LINQ API is a bunch of extension methods included in System.Linq.Enumerable and System.Linq.Queryable class.

6. Query alternative to the following SQL code in LINQ is : SELECT TOP 10 UPPER (c1.Name) FROM Customer c1 WHERE c1.Name LIKE 'A%' AND c1.ID NOT IN ( SELECT TOP 20 c2.ID FROM Customer c2 WHERE c2.Name LIKE 'A%' ORDER BY c2.Name ) ORDER BY c1.Name

Correct Answer is : var query = FROM c IN db.Customers WHERE c.Name.StartsWith ("A") orderby c.Name SELECT c.Name.ToUpper(); var thirdPage = query.Skip(20).Take(10);

7. Point out the correct statement :

Correct Answer is : All of the mentioned

8. LINQ query to retrieve a selection of customers, each with their high-value purchases is :

Correct Answer is : FROM c IN db.Customers WHERE c.Address.State == "WA" SELECT NEW { c.Name, c.CustomerNumber, HighValuePurchases = c.Purchases.Where (p => p.Price > 1000) }

9. LINQ Query to list all purchases of $1000 or greater made by customers who live in Washington :

Correct Answer is : FROM p IN db.Purchases WHERE p.Customer.Address.State == "WA" || p.Customer == NULL WHERE p.PurchaseItems.Sum (pi => pi.SaleAmount) > 1000 SELECT p

10. Point out the wrong statement :

Correct Answer is : Compared to SQL, LINQ is complex, tidier, and lower-level

11. public bool IsValidUser(string userName, string passWord) { DBNameDataContext myDB = NEW DBNameDataContext(); List users = myDB.Users.Where(u => u.Username == userName && u.Password==passWord); IF(users.Count>0) { RETURN TRUE; } RETURN FALSE; } This code is used will perform _________ operation in LINQ.

Correct Answer is : select

12. Which of the following code snippet would traverse through all result objects ?

Correct Answer is : foreach(USER USER IN userResults) { //checking the RESULT AS LIKE object IF(USER.Role == 'admin') { //do whatever you need } }

13. LINQ to SQL is considered to be one of Microsoft’s _______ products.

Correct Answer is : ORM

14. LINQ to SQL in SQL Server fully supports :

Correct Answer is : All of the mentioned

15. LINQ to Entities applications requires __________ mapping provider.

Correct Answer is : EntityClient

16. The ______ pre-compiler translates embedded SQL into calls to the Oracle runtime library.

Correct Answer is : Pro*C

17. Point out the correct statement :

Correct Answer is : If you want to work against a conceptual data model, use LINQ to Entities

18. DataContext object is constructed in LINQ to SQL using :

Correct Answer is : NorthwindDataContext db = new NorthwindDataContext();

19. Which of the following code will retrieve all products in the Beverages category sorted by product name ?

Correct Answer is : IEnumerable beverages = FROM p IN db.Products WHERE p.Category.CategoryName == "Beverages" orderby p.ProductName SELECT p;

20. Which of the following sample code is used to retrieve single row at a time ?

Correct Answer is : public USER GetUser(string userName) { DBNameDataContext myDB = NEW DBNameDataContext(); USER USER = myDB.Users.Single(u, u.UserName=>userName); RETURN USER; } ?

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon