Microsoft TS: Accessing Data with Microsoft .NET Framework 4 Sample Questions:
1. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that
uses the Entity Framework.
The application has an entity model that includes SalesTerritory and SalesPerson entities as shown in the
following diagram.
You need to calculate the total bonus for all sales people in each sales territory. Which code segment should you use?
A) model.SalesPersons .GroupBy(person => person.SalesTerritory) .SelectMany(group => group.Key.SalesPersons) .Sum(person => person.Bonus);
B) model.SalesTerritories .GroupBy(territory => territory.SalesPersons) .SelectMany(group => group.Key) .Sum(person => person.Bonus);
C) from territory in model.SalesTerritories group territory by territory.SalesPerson into personByTerritories select new {
SalesTerritory = personByTerritories.Key,
TotalBonus = personByTerritories.Key.Sum(person => person.Bonus)
};
D) from person in model.SalesPersons group person by person.SalesTerritory into territoryByPerson select new {
SalesTerritory = territoryByPerson.Key,
TotalBonus = territoryByPerson.Sum(person => person.Bonus)
};
2. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that
uses the Entity Framework.
You create the following Entity Data Model.
You add the following code fragment:
using(var context = new AdventureWorksLTEntities())
{ Customer cust = context.Customers.First(); cust.CompanyName = "Contoso"; int count = 0;
}
The changes to the cust entity must be saved. If an exception is thrown, the application will attempt to save
up to 3 times.
If not, an exception is thrown. Which code segment should you use?
A) while(context.ObjextStateManager.GetObjectStateEntry (cust).OriginalValues.IsDBNull(0)) {
if(count++ >2)
{
break;
}
context.SaveChanges();
}
B) while(cust.EntityState == EntityState.Modified)
{
try
{
context.SaveChanges();
}
catch(Exception)
{
if(count++ > 2 && context.Connection.State ==
ConnectionState.Broken
{
throw new Exception();
}
}
}
C) while(true)
{ context.SavingChanges += delegate(System.Object o, System.EventArgs e) {
if(count++ >2)
{
throw new Exception();
}
context.SaveChanges();
}
}
D) while(count++ < 3)
{
try
{
context.SaveChanges();
break;
}
catch(Exception)
{
}
}
3. The application must provide a component part list for any product. The component part list must give the
quantity of
each distinct part that is required to manufacture that product.
You need to create a LINQ expression that delivers a a result of type IEnumerable<Tuple<int,Part>> to
meet the requirements.
Which expression should you use?
A) IEnumerable<Tuple<int, Part>> result = part.Descendants .ToDictionary(c => c) .Select(d => Tuple.Create(d.Value.Children.Count(), d.Key));
B) IEnumerable<Tuple<int, Part>> result = part.Descendants .GroupBy(p => p) .Select(g => Tuple.Create(g.Count(), g.Key));
C) IEnumerable<Tuple<int, Part>> result = part.Descendants .Distinct() .GroupBy(p => p) .Select(g => Tuple.Create(g.Count(), g.Key));
D) IEnumerable<Tuple<int, Part>> result = part.Children .Distinct() .GroupBy(p => p) .Select(g => Tuple.Create(g.Count(), g.Key));
E) IEnumerable<Tuple<int, Part>> result = part.Children .GroupBy(p => p) .Select(g => Tuple.Create(g.Count(), g.Key));
4. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
You create an Entity Data Model (EDM) by using the Microsoft ADO.NET Entity Data Model Designer (Entity
Designer).
The EDM contains a complex type. You need to map a stored procedure to the complex type by using the
Entity Designer.
What should you do?
A) Add an association to the stored procedure.
B) Add an entity that mirrors the properties of the complex type.
C) Add a code generation item that has the name of the stored procedure.
D) Add a function import for the stored procedure.
5. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows Forms
application.
The application connects to a Microsoft SQL Server database.
You need to find out whether the application is explicitly closing or disposing SQL connections. Which code
segment should you use?
A) string instanceName = Assembly.GetEntryAssembly().GetName().Name; PerformanceCounter perf = new PerformanceCounter( ".NET Data Provider for SqlServer",
"NumberOfNonPooledConnections", instanceName, true); int leakedConnections = (int)perf.NextValue();
B) string instanceName = Assembly.GetEntryAssembly().FullName; PerformanceCounter perf = new PerformanceCounter( ".NET Data Provider for SqlServer",
"NumberOfNonPooledConnections", instanceName, true); int leakedConnections = (int)perf.NextValue();
C) string instanceName = Assembly.GetEntryAssembly().FullName; PerformanceCounter perf = new PerformanceCounter( ".NET Data Provider for SqlServer",
"NumberOfReclaimedConnections", instanceName, true); int leakedConnections = (int)perf.NextValue();
D) string instanceName = Assembly.GetEntryAssembly().GetName().Name; PerformanceCounter perf = new PerformanceCounter( ".NET Data Provider for SqlServer",
"NumberOfReclaimedConnections", instanceName, true); int leakedConnections = (int)perf.NextValue();
Solutions:
| Question # 1 Answer: D | Question # 2 Answer: B | Question # 3 Answer: B | Question # 4 Answer: D | Question # 5 Answer: C |














960 Customer Reviews
Quality and ValueITCertKing Practice Exams are written to the highest standards of technical accuracy, using only certified subject matter experts and published authors for development - no all study materials.
Tested and ApprovedWe are committed to the process of vendor and third party approvals. We believe professionals and executives alike deserve the confidence of quality coverage these authorizations provide.
Easy to PassIf you prepare for the exams using our ITCertKing testing engine, It is easy to succeed for all certifications in the first attempt. You don't have to deal with all dumps or any free torrent / rapidshare all stuff.
Try Before BuyITCertKing offers free demo of each product. You can check out the interface, question quality and usability of our practice exams before you decide to buy.
