[Free] Get all latest Microsoft 70-516 Actual Tests 131-140

Ensurepass

QUESTION 131

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You use the ADO.NET Entity Framework to model your entities. You use Plain Old CLR Objects (POCO) entities along with snapshot-based change tracking. The code accesses the POCO entities directly. You need to ensure that the state manager synchronizes when changes are made to the object graph. Which ObjectContext method should you call?

 

A.       Refresh

B.       SaveChanges

C.        DetectChanges

D.       ApplyPropertyChanges

 

Correct Answer: C

 

 

QUESTION 132

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application uses the ADO.NET Entity Framework to model entities. The application includes a Customer entity along with a CustomerKey property of the Guid type as shown in the following exhibit:

 

clip_image001

 

You discover that when the application adds a new instance of a Customer, calling the SaveChanges method results in the following error message: “Server generated keys are only supported for identity columns.” You need to ensure that the application can add new Customer entities. What should you do?

 

A.       Add a handler for the ObjectContext.SavingChanges event.

In the event handler, set the CustomerKey value.

B.       Add a handler for the ObjectContext.ObjectMaterialized event.

In the event handler, set the CustomerKey value.

C.        Call the ObjectContext.Attach method before saving a Customer entity.

D.       Call the ObjectContext.CreateEntityKey method before saving a Customer entity.

 

Correct Answer: A

 

 

QUESTION 133

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You use the ADO.NET Entity Framework to model entities. The application connects to a Microsoft SQL Server database named AdventureWorks. The application includes the following code segment. (Line numbers are included for reference only.)

 

01 using (AdventureWorksEntities context = new AdventureWorksEntities())

02 {

03 ObjectQuery <SalesOrderHeader> orders = context.SalesOrderHeader.

Where(“it.CreditCardApprovalCode IS

NULL”).Top(“100”);

04 foreach (SalesOrderHeader order in orders){

05 order.Status = 4;

06 }

07 try {

08 context.SaveChanges();

09 }

10 catch (OptimisticConcurrencyException){

11 …

12 }

13 }

 

You need to resolve any concurrency conflict that can occur. You also need to ensure that local changes are persisted to the database. Which code segment should you insert at line 11?

 

A.       context.Refresh(RefreshMode.ClientWins, orders);

context.AcceptAllChanges();

 

B.       context.Refresh(RefreshMode.ClientWins, orders);

context.SaveChanges();

 

C.        context.Refresh(RefreshMode.StoreWins, orders);

context.AcceptAllChanges();

 

D.       context.Refresh(RefreshMode.StoreWins, orders);

context.SaveChanges();

Correct Answer: B

 

 

QUESTION 134

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. The application uses the following object query to load a product from the database. (Line numbers are included for reference only.)

 

01 using (AdventureWorksEntities advWorksContext = new AdventureWorksEntities())

02 {

03 ObjectQuery <Product> productQuery = advWorksContext.Product.Where(“it.ProductID = 900”);

04 …

05 }

 

You need to log the command that the query executes against the data source. Which code segment should you insert at line 04?

 

A.       Trace.WriteLine(productQuery.ToString());

B.       Trace.WriteLine(productQuery.ToTraceString());

C.        Trace.WriteLine(productQuery.CommandText);

D.       Trace.WriteLine(((IQueryable)productQuery).Expression);

 

Correct Answer: B

 

 

QUESTION 135

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().FullName;

PerformanceCounter perf = new PerformanceCounter( “.NET Data Provider for SqlServer”, “NumberOfReclaimedConnections”, instanceName, true);

int leakedConnections = (int)perf.NextValue();

 

B.       string instanceName = Assembly.GetEntryAssembly().GetName().Name; PerformanceCounter perf = new PerformanceCounter( “.NET Data Provider for SqlServer”,

“NumberOfReclaimedConnections”, instanceName, true);

int leakedConnections = (int)perf.NextValue();

 

C.        string instanceName = Assembly.GetEntryAssembly().FullName;

PerformanceCounter perf = new PerformanceCounter( “.NET Data Provider for SqlServer”, “NumberOfNonPooledConnections”, instanceName, true);

int leakedConnections = (int)perf.NextValue();

 

D.       string instanceName = Assembly.GetEntryAssembly().GetName().Name; PerformanceCounter perf = new PerformanceCounter( “.NET Data Provider for SqlServer”,

“NumberOfNonPooledConnections”, instanceName, true);

int leakedConnections = (int)perf.NextValue();

 

Correct Answer: A

 

 

QUESTION 136

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You write the following code segment that executes two commands against the database within a transaction. (Line numbers are included for reference only.)

 

01 using(SqlConnection connection = new SqlConnection(cnnStr)) {

02 connnection.Open();

03 SqlTransaction sqlTran = connection.BeginTransaction();

04 SqlCommand command = connection.CreateCommand();

05 command.Transaction = sqlTran;

06 try{

07 command.CommandText = “INSERT INTO Production.ScrapReason(Name) VALUES(,,Wrong size)”;

08 command.ExecuteNonQuery();

09 command.CommandText = “INSERT INTO Production.ScrapReason(Name) VALUES(Wrong color)”;

10 command.ExecuteNonQuery();

11 … l2 }

 

You need to log error information if the transaction fails to commit or roll back. Which code segment should you insert at line 11?

 

A.         sqlTran.Commit();

}

catch (Exception ex) {

sqlTran.Rollback();

Trace.WriteLine(ex.Message);

}

 

B.         sqlTran.Commit();

}

catch (Exception ex) {

Trace.WriteLine(ex.Message);

try {

sqlTran.Rollback();

}

catch (Exception exRollback) {

Trace.WriteLine(exRollback.Message);

}

}

 

C.          catch (Exception ex){

Trace.WriteLine(ex.Message);

try{

sqlTran.Rollback();

}

catch (Exception exRollback){

Trace.WriteLine(exRollback.Message);

}

}

finaly {

sqltran.commit();

}

 

D.         catch (Exception ex) {

sqlTran.Rollback();

Trace.WriteLine(ex.Message);

}

finaly {

try {

sqltran.commit();

}

catch (Exception exRollback) {

Trace.WriteLine(excommit.Message);

}

}

 

Correct Answer: B

 

 

QUESTION 137

You use Microsoft Visual Studio 2010 and Microsoft.NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET LINQ to Entity model to retrieve data from the database. You need to call a function that is defined in the conceptual model from within the LINQ to Entities queries. You create a common language runtime (CLR) method that maps to the function. What should you do next?

 

A.       Declare the method as static.

B.       Declare the method as abstract.

C.        Apply the EdmFunctionAttribute attribute to the method.

D.       Apply the EdmComplexTypeAttribute attribute to the method.

 

Correct Answer: C

 

 

QUESTION 138

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You use Microsoft ADO.NET Entity Data Model (EDM) to model entities. You create an entity named Person with a schema defined by the following XML fragment.

 

<EntityType Name=”CPerson”>

<Key>

<PropertyRef Name=”PersonId” />

</Key>

<Property Name=”PersonId” Type=”Int32″ Nullable=”false” />

<Property Name=”CompanyName” Type=”String” />

<Property Name=”ContactName” Type=”String” />

<Property Name=”ContactTitle” Type=”String” />

<Property Name=”Address” Type=”String” />

</EntityType>

 

You need to ensure that entities within the application are able to add properties related to the city, region, and country of Person’s address. What should you do?

 

A.       Create a new complex type named CAddress that contains the properties for city, region, and country.

Change the Type of the Address property in CPerson to “Self.CAddress”.

 

B.       Create a SubEntity named Address.

Map the SubEntity to a stored procedure that retrieves city, region, and country.

 

C.        Create a new entity named Address.

Add a person ID property to filter the results to display only the City, Region, and Country properties for a specific Person entity.

 

D.       Create a view named Name that returns city, region, and country along with person IDs.

Add a WHERE clause to filter the results to display only the City, Region and Country properties for a specific Person entity.

 

Correct Answer: A

 

 

QUESTION 139

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET Entity Framework to model entities. You need to add a new type to your model that organizes scalar values within an entity. You also need to map stored procedures for managing instances of the type. What should you do?

 

A.         1. Add the stored procedures in the SSDL file along with a Function attribute.

2. Define a complex type in the CSDL file.

3. Map the stored procedure in the MSL file with a ModificationFunctionElement.

 

B.         1. Add the stored procedures in the SSDL file along with a Function attribute.

2. Define a complex type in the CSDL file.

3. Map the stored procedure in the MSL file with an AssociationEnd element.

 

C.          1. Use the edmx designer to import the stored procedures.

2. Derive an entity class from the existing entity as a complex type.

3. Map the stored procedure in the MSL file with an AssociationEnd element.

 

D.         1. Add the stored procedures in the SSDL file along with a Function attribute.

2. Derive an entity class from the existing entity as a complex type.

3. Map the stored procedure in the MSL file with a ModificationFunctionElement.

 

Correct Answer: A

 

 

QUESTION 140

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Microsoft ASP.NET application. You want to connect the application to a Microsoft SQL Server Express 2008 database named MyDatabase. The primary database file is named MyDatabase.mdf and it is stored in the App_Data folder. You need to define the connection string. Which connection string should you add to the Web.config file?

 

A.       Data Source=localhost; Initial Catalog=MyDataBase; Integrated Security=SSPI; User Instance=True

B.       Data Source=.SQLEXPRESS; Initial Catalog=MyDataBase; Integrated Security=True; User Instance=True

C.        Data Source=.SQLEXPRESS; AttachDbFilename=|DataDirectory|MyDatabase.mdf; Integrated Security=True; User Instance=True

D.       Data Source=.SQLEXPRESS; AttachDbFilename=|DataDirectory|App_DataMyDatabase.mdf; Integrated Security=SSPI; User Instance=True

 

Correct Answer: C

 

Instant Access to Download Testing Software & PDF File for Microsoft 70-516 Real Exam

Instant Access to Try Microsoft 70-516 Free Demo

 

 

This entry was posted in 70-516 Actual Tests and tagged , , , , , . Bookmark the permalink.