[Pass Ensure VCE Dumps] New Version 286q 70-516 Exam VCE and PDF Dumps Collection (121-140)
Want To Pass The New 70-516 Exam Easily? DO NOT WORRY! PassLeader now is supplying the latest and 100 percent pass ensure 286q 70-516 PDF dumps and VCE dumps, the new updated 70-516 braindumps are the most accurate with all the new changed 70-516 exam questions, it will help you passing 70-516 exam easily and quickly. Now visit the our site passleader.com and get the valid 286q 70-516 VCE and PDF exam questions and FREE VCE PLAYER!
keywords: 70-516 exam,286q 70-516 exam dumps,286q 70-516 exam questions,70-516 pdf dumps,70-516 vce dumps,70-516 braindumps,70-516 practice tests,70-516 study guide,TS: Accessing Data with Microsoft .NET Framework 4 Exam
QUESTION 121
You want to execute a SQL insert statement from your client application, so you set the CommandText property of the command object and open the connection. Which method will you execute on the command?
A. ExecuteScalar
B. ExecuteXmlReader
C. ExecuteReader
D. ExecuteNonQuery
QUESTION 122
In ADO.NET, which class can start an explicit transaction to update a SQL Server database?
A. SqlCommand
B. SqlConnection
C. SqlParameter
D. SqlException
Answer: B
QUESTION 123
You want to store the contents of a data set to an XML file so you can work on the data while disconnected from the database server. How should you store this data?
A. As a SOAP file
B. As a DataGram file
C. As a WSDL file
D. As an XML Schema file
Answer: B
QUESTION 124
To which of the following types can you add an extension method? (Each correct answer presents a complete solution. Choose five.)
A. Class
B. Structure (C# struct)
C. Module (C# static class)
D. Enum
E. Interface
F. Delegate
Answer: ABDEF
QUESTION 125
You want to page through an element sequence, displaying ten elements at a time, until you reach the end of the sequence. Which query extension method can you use to accomplish this? (Each correct answer presents part of a complete solution. Choose two.)
A. Skip
B. Except
C. SelectMany
D. Take
Answer: AD
QUESTION 126
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You use the ADO.NET Entity Data Model (EDM) to define a Customer entity. You need to add a new Customer to the data store without setting all the customer’s properties. What should you do?
A. Call the Create method of the Customer object.
B. Call the CreateObject method of the Customer object.
C. Override the Create method for the Customer object.
D. Override the SaveChanges method for the Customer object.
Answer: B
Explanation:
CreateObject<T> Creates and returns an instance of the requested type.
QUESTION 127
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server 2008 database. You use the ADO.NET Entity Framework to model your entities. You use ADO.NET self-tracking entities. You need to ensure that the change-tracking information for the self-tracking entities can be used to update the database. Which ObjectContext method should you call after changes are made to the entities?
A. Attach
B. Refresh
C. SaveChanges
D. ApplyChanges
Answer: D
Explanation:
ApplyChanges takes the changes in a connected set of entities and applies them to an ObjectContext.
Starting with Microsoft Visual Studio 2010, the ADO.NET Self-Tracking Entity Generator template generates self-tracking entities.
This template item generates two .tt (text template) files: <model name>.tt and <model name>.Context.tt.
The <model name>.tt file generates the entity types and a helper class that contains the change-tracking logic that is used by self-tracking entities and the extension methods that allow setting state on self-tracking entities.
The <model name>.Context.tt file generates a typed ObjectContext and an extension class that contains ApplyChanges methods for the ObjectContext and ObjectSet classes. These methods examine the change-tracking information that is contained in the graph of self- tracking entities to infer the set of operations that must be performed to save the changes in the database.
Working with Self-Tracking Entities
http://msdn.microsoft.com/en-us/library/ff407090.aspx
QUESTION 128
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 manage Plain Old CLR Objects (POCO) entities. You create a new POCO class. You need to ensure that the class meets the following requirements:
– It can be used by an ObjectContext.
– It is enabled for change-tracking proxies.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Modify each mapped property to contain sealed and protected accessors.
B. Modify each mapped property to contain non-sealed, public, and virtual accessors.
C. Configure the navigation property to return a type that implements the ICollection interface.
D. Configure the navigation property to return a type that implements the IQueryable interface.
E. Configure the navigation property to return a type that implements the IEntityWithRelationships interface.
Answer: BC
Explanation:
CHAPTER 6 ADO.NET Entity Framework
Lesson 1: What Is the ADO.NET Entity Framework?
Other POCO Considerations (page 412)
QUESTION 129
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 allows users to make changes while disconnected from the data store. Changes are submitted to the data store by using the SubmitChanges method of the DataContext object. You receive an exception when you call the SubmitChanges method to submit entities that a user has changed in offline mode. You need to ensure that entities changed in offline mode can be successfully updated in the data store. What should you do?
A. Set the ObjectTrackingEnabled property of DataContext to true.
B. Set the DeferredLoadingEnabled property of DataContext to true.
C. Call the SaveChanges method of DataContext with a value of false.
D. Call the SubmitChanges method of DataContext with a value of System.Data.Linq.ConflictMode.ContinueOnConflict.
Answer: A
Explanation:
ObjectTrackingEnabled Instructs the framework to track the original value and object identity for this DataContext.
ObjectTrackingEnabled Property
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.objecttrackingenabled.aspx
QUESTION 130
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 ADO.NET LINQ to SQL model to retrieve data from the database. The application will not modify retrieved data. You need to ensure that all the requested data is retrieved. You want to achieve this goal using the minimum amount of resources. What should you do?
A. Set ObjectTrackingEnabled to true on the DataContext class.
B. Set ObjectTrackingEnabled to false on the DataContext class.
C. Set DeferredLoadingEnabled to true on the DataContext class.
D. Set DeferredLoadingEnabled to false on the DataContext class.
Answer: B
Explanation:
Setting property ObjectTrackingEnabled to false improves performance at retrieval time, because there are fewer items to track.
DataContext.ObjectTrackingEnabled Property
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.objecttrackingenabled.aspx
http://www.passleader.com/70-516.html
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
Answer: C
Explanation:
When working with POCO, you must call the DetectChanges method on the ObjectContext to attach the POCO entity to the ObjectContext. Be sure to call DetectChanges prior to calling SaveChanges. ApplyPropertyChanges Obsolete. Applies property changes from a detached object to an object already attached to the object context.
CHAPTER 6 ADO.NET Entity Framework
Lesson 2: Querying and Updating with the Entity Framework Attaching Entities to an ObjectContext (page 438)
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. 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.
Answer: A
Explanation:
SavingChanges() Event Occurs when changes are saved to the data source. ObjectMaterialized() Event Occurs when a new entity object is created from data in the data source as part of a query or load operation. Attach() Method Attaches an object or object graph to the object context when the object has an entity key. CreateEntityKey() Creates the entity key for a specific object, or returns the entity key if it already exists.
ObjectContext Class
http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.aspx
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();
Answer: B
Explanation:
SaveChanges() Persists all updates to the data source and resets change tracking in the object context.
Refresh(RefreshMode, Object) Updates an object in the object context with data from the data source.
AcceptAllChanges() Accepts all changes made to objects in the object context. Refresh(RefreshMode refreshMode, Object entity) Method has the dual purpose of allowing an object to be refreshed with data from the data source and being the mechanism by which conflicts can be resolved.
ObjectContext.Refresh Method
http://msdn.microsoft.com/en-us/library/bb896255.aspx
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);
Answer: B
Explanation:
CHAPTER 8 Developing Reliable Applications
Lesson 1: Monitoring and Collecting Performance Data Accessing SQL Generated by the Entity Framework (page 509)
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();
Answer: A
Explanation:
NumberOfNonPooledConnections The number of active connections that are not pooled. NumberOfReclaimedConnections The number of connections that have been reclaimed through garbage collection where Close or Dispose was not called by the application. Not explicitly closing or disposing connections hurts performance.
Use of ADO.NET performance counters
http://msdn.microsoft.com/en-us/library/ms254503(v=vs.80).aspx
Assembly Class
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx
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 …
12 }
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);
}
}
Answer: B
Explanation:
A would work, but B is better since we are checking for possible errors during the rollback. C & D would try to do a rollback before a commit? The finally block is only executed when the application ends, which may not be the appropriate place to put this logic. Normally, a finally block would contain code to close a Database connection. The finally block executes even if an exception arises.
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.
Answer: C
Explanation:
CHAPTER 6 ADO.NET Entity Framework
Lesson 1: What Is the ADO.NET Entity Framework?
Model-Defined Functions (page 413-414)
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.
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.
Answer: A
Explanation:
EndProperty Element (MSL)
http://msdn.microsoft.com/en-us/library/bb399578.aspx
AssosiationEnd Attribute
http://msdn.microsoft.com/en-us/library/cc716774.aspx
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_Data\MyDatabase.mdf; Integrated Security=SSPI; User Instance=True
Answer: C
Explanation:
CHAPTER 2 ADO.NET Connected Classes
Lesson 1: Connecting to the Data Store
Attaching to a Local SQL Database File with SQL Express (page 73)