QUESTION 41
You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 200B database.
You populate a SqlDataAdapter by using the following code. (Line numbers are included for reference only.)
01 SqlDataAdapter dataAdapterl = new SqlDataAdapter
(“SELECT * FROM [BlogEntries]
ORDER BY CreationDote”, connection);
02 cmdBuilder = nev SqlCormnandBuilder(dataAdapterl);
03 dataAdapterl.Fill(BlogEntryDataSet, “BlogEntries”);
04
05 connection.Close()
You need to update the blog owner for all BlogEntry records.
Which code segment should you insert at line 04?
A. |
foreach(DataRou row in BlogEntryDataSet.Tables [“BlogEntries”].ROWS) { row.Item[“BlogOwner””] = “New Owner”; } dataAdapterl.Update(BlogEntryDataSet, “BlogEntries”); |
B. |
foreach(DataRow row in BlogEntryDataSet.Tables [“BlogEntries”].Rows) ( tow.Item[“Blog0wner””] = “New Owner”; } dataAdapterl.Fill(BlogEntryDataSet, “BlogEntries”); |
C. |
SqlDataAdapter dataAdapter2 = new SqlDataAdapter (“UPDATE [BlogEntries] SET [BlogOwner = ‘New ‘Owner’ 3”, connection); dataAdapter2-Update(BlogEntryDataSet, “BlogEntries”); |
D. |
SqlDataAdapter dataAdapter2 = new SqlDataAdapter (dataAdapterl.UpdateCommand) ; dataAdapter2.Fill(BlogEntryDataSet, “BlogEntries”); |
Correct Answer: A
Explanation:
SqlDataAdapter.Update() – Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the System.Data.DataSet with the specified System.Data.DataTable name.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx
QUESTION 42
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application contains the following XML document.
< feed >
< title > Products < /title >
< entry >
< title > Entry title 1 < /title >
< author > Author1 < /title >
< content >
< properties >
< description > some description < /description >
< n otes > some notes < /notes >
< comments > some comments < /comments >
< /properties >
< /content >
< /entry >
…
< /feed >
You plan to add localization features to the application.
You add the following code segment. (Line numbers are included for reference only.)
01 public IEnumerable < XNode > GetTextNodesForLocalization(XDocument doc)
02 {
03
04 return from n in nodes
05 where n.NodeType == XmlNodeType.Text
06 select n;
07 }
You need to ensure that the GetTextNodesForLocalization method returns all the XML text nodes of the document.
Which code segment should you insert at line 03?
A. |
IEnumerable < XNode > nodes = doc.DescendantNodes(); |
B. |
IEnumerable < XNode > nodes = doc.Nodes(); |
C. |
IEnumerable < XNode > nodes = doc.Descendants(); |
D. |
IEnumerable < XNode > nodes = doc.NodesAfterSelf(); |
Correct Answer: A
Explanation:
DescendantNodes() Returns a collection of the descendant nodes for this document or element, in document order.
Descendants() Returns a collection of the descendant elements for this document or element, in document order.
Nodes() Returns a collection of the child nodes of this element or document, in document order.
NodesAfterSelf() Returns a collection of the sibling nodes after this node, in document order
QUESTION 43
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application updates several Microsoft SQL Server databases within a single transaction.
You need to ensure that after a resource failure, you can manage unresolved transactions.
What should you do?
A. |
Call the EnlistVolatile method of the Transaction class. |
B. |
Call the Reenlist method of the TransactionManager class. |
C. |
Call the EnlistDurable method of the Transaction class. |
D. |
Call the RecoveryComplete method of the TransactionManager class. |
Correct Answer: B
Explanation:
Enlisting Resources as Participants in a Transaction
http://msdn.microsoft.com/en-us/library/ms172153.aspx
Implementing a Resource Manager
http://msdn.microsoft.com/en-us/library/ms229975.aspx
Committing a Transaction in Single-Phase and Multi-Phase
http://msdn.microsoft.com/en-us/library/ckawh9ct.aspx
TransactionManager.Reenlist() Reenlists a durable participant in a transaction. A resource manager facilitates resolution of durable enlistments in a transaction by reenlisting the transaction participant after resource failure.
Transaction.EnlistVolatile() Enlists a volatile resource manager to participate in a transaction. Volatile resource managers cannot recovery from failure to complete a transaction in which they were participating.
Transaction.EnlistDurable() Enlists a durable resource manager to participate in a transaction.
TransactionManager.RecoveryComplete() Notifies the transaction manager that a resource manager recovering from failure has finished reenlisting in all unresolved transactions. All durable resource managers should do recovery when they first start up by calling the Reenlist method for each outstanding transaction. Only when all of the reenlistments are done should the resource manager call RecoveryComplete.
TransactionManager.Reenlist() Method
http://msdn.microsoft.com/en-us/library/system.transactions.transactionmanager.reenlist.aspx
Transaction.EnlistVolatile() Method
http://msdn.microsoft.com/en-us/library/system.transactions.transaction.enlistvolatile.aspx
Transaction.EnlistDurable()
http://msdn.microsoft.com/en-us/library/system.transactions.transaction.enlistdurable.aspx
TransactionManager.RecoveryComplete() Method
http://msdn.microsoft.com/en-us/library/system.transactions.transactionmanager.recoverycomplete.aspx
QUESTION 44
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the ADO.NET Entity Framework to model entities. You create an entity model as shown in the following diagram.
You need to ensure that all Person entities and their associated EmailAddresses are loaded.
Which code segment should you use?
A. |
var people = context.People.Include (“EmailAddresses”).ToList(); |
B. |
var people = context.People.Except (new ObjectQuery<Person>(“Person.EmailAddresses”, context)).ToList(); |
C. |
var people = context.People.Except (new OtajectQuery<Person>(“EmailAddresses”, context)).ToList(); |
D. |
var people = context.People.Include (“Person.EmailAddresses”).ToList(); |
Correct Answer: A
Explanation:
CHAPTER 6 ADO.NET Entity Framework
Lesson 1: What Is the ADO.NET Entity Framework?
Lazy Loading vs. Explicit Loading vs. Eager Loading (page 384)
http://msdn.microsoft.com/en-us/library/bb896272.aspx
QUESTION 45
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.
You manually create your own Context class named AdventureWorksDB that inherits from Object Context.
You need to use Adventure WorksDB to invoke a stored procedure that is defined in the data source.
Which method should you call?
A. |
Translate |
B. |
ExecuteFunction |
C. |
ExecuteStoreQuery |
D. |
ExecuteStoreCommand |
Correct Answer: B
Explanation:
ExecuteFunction(String, ObjectParameter[]) Executes a stored procedure or function that is defined in the data source and expressed in the conceptual model; discards any results returned from the function; and returns the number of rows affected by the execution.
ExecuteStoreCommand() Executes an arbitrary command directly against the data source using the existing connection.
ExecuteStoreQuery<TElement>(String, Object[]) Executes a query directly against the data source that returns a sequence of typed results.
Translate<TElement>(DbDataReader) Translates a DbDataReader that contains rows of entity data to objects of the requested entity type.
ObjectContext.ExecuteFunction Method
http://msdn.microsoft.com/en-us/library/dd986915.aspx
QUESTION 46
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. You use the ADO.NET Entity Framework Designer to model entities. The application includes self-tracking entities as shown in the following diagram.
There is a Person entity named person1 that has Track Changes turned on.
You need to delete all e-mail addresses that are associated with person1 by using an ObjectContext named context.
What are two possible code segments that you can use to achieve this goal? (Each correct answer presents a complete solution. Choose two).
A. |
foreach(var email in person1.EmailAddresses) { email.MarkAsDeleted(); } context.SaveChanges(); |
B. |
while(person1.EmailAddresses.Count() > 0) { person1.EmailAddresses.RemoveAt(0); } context.SaveChanges(); |
C. |
person1.EmailAddresses = null; context.SaveChanges(); |
D. |
person1.EmailAddresses = new TrackableCollection<EmailAddress>(); context.SaveChanges(); |
Correct Answer: BC
Explanation:
Working with Self-Tracking Entities
http://msdn.microsoft.com/en-us/library/ff407090.aspx
Working with Sets of Self-Tracking Entities
http://blogs.msdn.com/b/adone
t/archive/2010/06/02/working-with-sets-of-self-tracking-entities.aspx
QUESTION 47
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. The application defines the following Entity Data Model.
Within the .edmx file, the following function is defined,
<Funccion Naroe=”Round” ReturnType=”Decimal”>
<Parameter Name=”val” Type=”Decimal” />
<DefiningExpression>
CAST(val as Edm.Int32)
</DefiningExpcession>
</Function>
The application includes the following LINQ query.
var query = from detail in context.SalesOrderDetails
select detail.LineTotal.Round() ;
You need to ensure that the Round function executes on the database server when the query is executed.
Which code segment should you use?
A. |
public static class DecimalHelper { [EdmFunction(“SqlServer”, “Round”) ] public static Decimal Round(this Decimal Amt) { throw new NotSupportedExceptionf); } } |
B. |
public static class DecimalHelper { [EdmFunction(“Edm”, “Round”) ] public static Decimal Round(this Decimal Amt) { throw new NotSupportedException(); } } |
C. |
public static class DecimalHelper { public static SqlDecimal Round(this Decimal input) < return SqlDecimal.Round(input, 0); } } |
D. |
public static class DecimalHelper { public static Decimal Round(this Decimal input) { return (Decimal)(Int32)input; } } |
Correct Answer: B
Explanation:
EdmFunctionAttribute Class
http://msdn.microsoft.com/en-us/library/system.data.objects.dataclasses.edmfunctionattribute.aspx
How to: Call Model-Defined Functions in Queries
http://msdn.microsoft.com/en-us/library/dd456857.aspx
The model-defined function has been created in the conceptual model, but you still need a way to connect your code to it.
To do so, add a function into your C# code, which will have to be annotated with the EdmFunctionAttribute attribute.
This function can be another instance method of the class itself, but best practice is to create a separate class and define this method as static.
QUESTION 48
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.
The application connects to a Microsoft SQL Server database.
You load records from a table named Products to a DataTable named dataTable.
You populate a SqIDataAdapter by using the following code:
You need to ensure that optimistic concurrency is enforced on the Update call.
Which code should you insert at line 08?
A. |
P1.SourceVersion = System.Data.DataRowVersion.Current; |
B. |
P1. SourceVersion = System.Eata.DataRowVersion.Original; |
C. |
P1.SourceVersion = System.Data.DataRowVersion.Default; |
D. |
P1.SourceVersion = System.Data.DataRowVersion.Proposed; |
Correct Ans
wer: B
QUESTION 49
You use Microsoft .NET Framework 4 to develop an application that exposes a WCF Data Services endpoint.
The endpoint uses an authentication scheme that requires an HTTP request that has the following header format.
GET /OData.svc/Products(1)
Authorization: WRAP access_token “123456789”
You add the following method to your DataService implementation.
protected override void OnStartProcessingRequest
(ProcessRequestArgs args)
{
…
}
You need to ensure that the method retrieves the authentication token.
Which line of code should you use?
A. |
string token = args.OperationContext.RequestHeaders[“Authorization”]; |
B. |
string token = args.OperationContext.RequestHeaders[“WRAP access token”]; |
C. |
string token = args.OperationContext.ResponseHeaders[“Authorization”] ; |
D. |
string token = args.OperationContext.ResponseHeaders[“WRAP access token”]; |
Correct Answer: A
Explanation:
OData and Authentication – OAuth WRAP
http://blogs.msdn.com/b/astoriateam/archive/2010/08/19/odata-and-authentication-part-8-oauth-wrap.aspx
QUESTION 50
You develop a Microsoft .NET Framework 4 application that uses the Entity Framework to store entities in a Microsoft SQLServer2008 database. While the application is disconnected from the database, entities that are added or modified are serialized to a local file.
The next time the application connects to the database, it retrieves a Customer entity from the database by using an object context named context and stores the entity in a variable named remoteCustomer. The application then deserializes the Customer entity from the local file and stores the entity in a variable named localCustomer. The remoteCustomer and the localCustomer variables have the same entity key.
You need to ensure that the offline changes to the Customer entity are persisted in the database when the ObjectContext.SaveChanges() method is called.
Which line of code should you use?
A. |
context.ApplyOriginalValues(“Customers”, remoteCustomer); |
B. |
context.ApplyOriginalValues(“Customers”, localCustomer); |
C. |
context.ApplyCurrentValues(“Customers”, rem oteCustomer); |
D. |
context.ApplyCurrentValues(“Customers”, localCustomer); |
Correct Answer: D
Explanation:
http://msdn.microsoft.com/en-us/library/dd487246.aspx
Free VCE & PDF File for Microsoft 70-516 Real Exam
Instant Access to Free VCE Files: MCSE|MCSA|MCITP…
Instant Access to Free PDF Files: MCSE|MCSA|MCITP…
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF