adplus-dvertising
frame-decoration

Question

Which of the following code in LINQ performs functionality similar to joins in SQL?

a.

var categoryProducts =
FROM c IN db.Categories
SELECT NEW {c.CategoryName, productCount = products.Count()};
foreach (var cp IN categoryProducts)
{
Console.WriteLine("There are {0} products in category {1}",
cp.CategoryName, cp.productCount);
}

b.

var categoryProducts =
FROM c IN db.Categories
JOIN p IN db.Products ON c.CategoryID equals p.CategoryID INTO products
SELECT NEW {c.CategoryName, productCount = products.Count()};
foreach (var cp IN categoryProducts)
{
Console.WriteLine("There are {0} products in category {1}",
cp.CategoryName, cp.productCount);
}

c.

var categoryProducts =
FROM c IN db.Categories
JOIN p IN db.Products ON c.CategoryID equals p.CategoryID INTO products
foreach (var cp IN categoryProducts)
{
Console.WriteLine("There are {0} products in category {1}",
cp.CategoryName, cp.productCount);
}

d.

None of the mentioned

Posted under SQL Server

Answer: (b).var categoryProducts =
FROM c IN db.Categories
JOIN p IN db.Products ON c.CategoryID equals p.CategoryID INTO products
SELECT NEW {c.CategoryName, productCount = products.Count()};
foreach (var cp IN categoryProducts)
{
Console.WriteLine("There are {0} products in category {1}",
cp.CategoryName, cp.productCount);
}

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following code in LINQ performs functionality similar to joins in SQL?

Similar Questions

Discover Related MCQs

Q. Service broker was added to SQL Server ___________

Q. Point out the correct statement.

Q. There are _________ components of the Service broker in SQL Server.

Q. Which of the following service broker component defines the infrastructure used for exchanging messages between instances?

Q. Point out the wrong statement.

Q. Service Broker also provides security by preventing __________ access from networks and by message encryption.

Q. (SSBS) is a new architecture which allows you to write ____________ message based application.

Q. Which of the following change was introduced in SQL Server 2012 related to Service Broker?

Q. Which of the following is a Service Broker Related Dynamic Management View?

Q. Which of the utility is used for reporting the issue in Service Broker?

Q. ___________ is a set of technologies for copying and distributing data and database objects from one database to another.

Q. Point out the correct statement.

Q. How many types of replication is provided by SQL Server?

Q. Replication in SQL Server is used to overcome ________________

Q. Point out the wrong statement.

Q. Which of the following stored procedure provide replication support for AlwaysOn?

Q. How many types of replication components are present in SQL Server?

Q. Which of the following makes data available for replication?

Q. Two types of subscriptions present for replication is _____________

Q. SSMS provides different options to develop your SSIS package starting with ___________ wizard.