[Free] New Updated (October) Microsoft 70-516 Real Exam 11-20

Ensurepass

 


 

 

 

QUESTION 11

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database.

 

The application has two DataTable objects that reference the Customers and Orders tables in the database.

 

The application contains the following code segment. (Line numbers are included for reference only.)

 

01 DataSet customerOrders = new DataSet();

 

02 customerOrders.EnforceConstraints = true;

 

03 ForeignKeyConstraint ordersFK = new ForeignKeyConstraint(“ordersFK”,

 

04 customerOrders.Tables[“Customers”].Columns[“CustomerID”],

 

05 customerOrders.Tables[“Orders”].Columns[“CustomerID”]);

 

06

 

07 customerOrders.Tables[“Orders”].Constraints.Add(ordersFK);

 

You need to ensure that an exception is thrown when you attempt to delete Customer records that have related Order records.

 

Which code segment should you insert at line 06?

 

A.

ordersFK.DeleteRule = Rule.SetDefault;

B.

ordersFK.DeleteRule = Rule.None;

C.

ordersFK.DeleteRule = Rule.SetNull;

D.

ordersFK.DeleteRule = Rule.Cascade;

 

Correct Answer: B

Explanation:

None No action taken on related rows, but exceptions are generated. Cascade Delete or update related rows. This is the default.

SetNull Set values in related rows to DBNull.

SetDefault Set values in related rows to the value contained in the DefaultValue property. SetDefault specifies that all child column values be set to the default value.

CHAPTER 1 ADO.NET Disconnected Classes

Lesson 1: Working with the DataTable and DataSet Classes Cascading Deletes and Cascading Updates (page 26)

 

 

QUESTION 12

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 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

Explanation:

CHAPTER 8 Developing Reliable Applications

Lesson 1: Monitoring and Collecting Performance Data Accessing SQL Generated by the Entity Framework (page 509)

 

 

QUESTION 13

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 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

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 14

You are developing an ADO.NET 4 application that interacts with a Microsoft SQL Server 2008 server through the SQL Server Native Client. You create a trace DLL registry entry and you register all of the trace schemas. You need to trace the application data access layer. Which control GUID file should you use?

 

A.

ctrl.guid.snac10

B.

ctrl.guid.mdac

C.

ctrl.guid.adonet

D.

ctrl.guid.msdadiag

 

Correct Answer: A

Explanation:

ctrl.guid.adonet – ADO.NET only

ctrl.guid.msdadiag – MSDADIAG only

ctrl.guid.snac10 – SQL Server Native Client Providers only (SQL Server 2008) ctrl.guid.mdac – Windows Data Access Components (formerly Microsoft Data Access Components) on Windows 7 only

Data Access Tracing in SQL Server 2008

http://msdn.microsoft.com/en-us/library/cc765421.aspx

 

 

QUESTION 15

DRAG DROP

You are developing code that creates database connection objects.

 

You plan to create connections by using the DbProvideFactory class.

 

You need to ensure that the factory creates a connection to Microsoft SQL Server.

 

What should you do?

 

To answer, drag the appropriate elements to the correct locations. Each element may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

 

clip_image002

 

Correct Answer:

clip_image004

 

 

QUESTION 16

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses LINQ to SQL. The application contains the following model.

 

clip_image006

 

You write the following code. (Line numbers are included for reference only.)

 

01 static void Insect()

 

02 {

 

03 NorthwindDataContext dc = new NorthwindDataContext();

 

04 Customer newCustomer = new Customer();

 

05 newCustomer.Firstname = “Todd”;

 

06 newCustomer.Lastname = “Meadows”;

 

07 newCustomer.Email = “troeadows@contoso.com”;

 

08

 

09 dc.SubmitChanges();

 

10 {

 

A product named Bike Tire exists in the Products table. The new customer orders the Bike Tire product.

 

You need to ensure that the correct product is added to the order and that the order is associated with the new customer.

 

Which code segment should you insert at line 08?

 

A.

Order newOrder = new Order();

newOrder.Product = (from p in dc.Products

where p.ProductName == “Bike Tire”

select p) .First();

B.

Product newProduct = new Product();

newProduct.ProductName = “Bike Tire”; Order

newOrder = new Order();

newOrder.Product = newProduct;

C.

Product newProduct = new Product();

newProduct.ProductName = “Bike Tire”;

Order newOrder = new Order ();

newOrder.Product = newProduct;

newCustomer.Orders.Add(newOrder) ;

D.

Order newOrder = new Order();

newOrder.Product = (from p in dc.Products

where p.ProductName == “Bike Tire”

select p).First();

newCustomer.Orders.Add(newOrder) ;

 

Correct Answer: D

 

 

QUESTION 17

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. The application has an entity model that contains a SalesOrderHeader entity. The entity includes an OrderDate property of type DateTime. You need to retrieve the 10 oldest SalesOrderHeaders according to the OrderDate property. Which code segment should you use?

 

A.

var model = new AdventureWorksEntities();

var sales = model.SalesOrderHeaders.Take(10).OrderByDescending(soh => soh.OrderDate);

B.

var model = new AdventureWorksEntities();

var sales = model.SalesOrderHeaders.OrderByDescending(soh => soh.OrderDate).Take(10);

C.

var model = new AdventureWorksEntities();

var sales = model.SalesOrderHeaders.OrderBy(soh => soh.OrderDate).Take(10);

D.

var model = new AdventureWorksEntities();

var sales = model.SalesOrderHeaders.Take(10).OrderBy(soh => soh.OrderDate);

 

Correct Answer: C

Explanation:

OrderBy() Sorts the elements of a sequence in ascending order according to a key. OrderByDescending() Sorts the elements of a sequence in descending order according to a key.

Enumerable.OrderBy<TSource, TKey> Method (IEnumerable<TSource>, Func<TSource, TKey>)

http://msdn.microsoft.com/en-us/library/bb534966.aspx

 

 

QUESTION 18

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. You use the Entity Framework Designer to create the following Entity Data Model.

 

clip_image007

 

You write a method named ValidatePostalCode to validate the postal code for the application.

 

You need to ensure that the ValidatePostalCode method is called before the PostalCode property set method is completed and before the underlying value has changed.

 

Which code segment should you place in the entity’s partial class?

 

A.

partial void OnPostalCodeChanged(string value) {

PostalCode – GetValidValue<string>

(value, “ValidatePostalCode”, false, true);

}

B.

public string ValidatedPostalCode

{

set ( ValidatePostalCode(value); _PostalCode = value; }

get

{

return _PostalCode;

}

C.

partial void OnPostalCodeChanging(string value) {

ValidatePostalCode(value);

}

D.

public string ValidatedPostalCode

{

set

{

_PostalCode = StructuralObject.SetValidValue (“ValidatePostalCode”, false); }

get

{

return _PostalCode;

}

}

 

Correct Answer: C

Explanation:

Another area of extensibility is with the partial methods created on each entity type. There is a pair of partial methods called OnXxxChanging and OnXxxChanged for each property, in which Xxx is the name of the property. The OnXxxChanging method executes before the property has changed, and the OnXxxChanged method executes after the property has changed. To implement any of the partial methods, create a partial class and add the appropriate partial method with implementation code.

 

CHAPTER 6 ADO.NET Entity Framework

Lesson 1: What Is the ADO.NET Entity Framework?

Partial Classes and Methods(page 390)

 

How to: Execute Business Logic During Scalar Property Changes

http://msdn.microsoft.com/en-us/library/cc716747.aspx

 

 

QUESTION 19

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The apphcation connects to a Microsoft SQL Server database. The application stores user names and passwords in the database. You need to ensure mat users cannot reao passwards extracted irom the database. What should you do?

 

A.

Encrypt stored passwords by using the RC2CryptoServiceProvider class.

B.

Encrypt stored passwords by using the TripleDESCryptoServiceProvider class.

C.

Append a salt to the password by using the RNGCryptoServiceProvider class. Encrypt stored passwords by using the RijndaelManaged class.

D.

Append a salt to the password by using the RNGCryptoServiceProvider class. Hash stored passwords by using the SHA1CryptoServiceProvider class.

 

Correct Answer: D

Explanation:

SHA1CryptoServiceProvider Class Computes the SHA1 hash value for the input data using the implementation provided by the cryptographic service provider (CSP). This class cannot be inherited.

SHA1CryptoServiceProvider Class

http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1cryptoserviceprovider.aspx

CHAPTER 8 Developing Reliable Applications

Lesson 3: Protecting Your Data

Hashing and Salting (page 550-551)

QUESTION 20

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application uses the ADO.NET Entity Framework to model entities.

 

The conceptual schema definition language (CSDL) file contains the following XML fragment.

 

< EntityType Name=”Contact”>

 

 

<Property Name=”EmailPhoneComplexProperty”

 

Type=”AdventureWorksModel.EmailPhone”

 

Nullable=”false” />

 

</EntityType>

 

 

<ComplexType Name=”EmailPhone”>

 

<Property Type=

“String” Name=”EmailAddress”

 

MaxLength=”50″ FixedLength=”false”

 

Unicode=”true” />

 

<Property Type=”String” Name=”Phone” MaxLength=”25″

 

FixedLength=”false” Unicode=”true” />

 

</ComplexType>

 

You write the following code segment. (Line numbers are included for reference only.)

 

01 using (EntityConnection conn = new EntityConnection(“name=AdvWksEntities”))

 

02 {

 

03 conn.Open();

 

04 string esqlQuery = @”SELECT VALUE contacts FROM

 

05 AdvWksEntities.Contacts AS contacts

 

06 WHERE contacts.Con

tactID == 3″;

 

07 using (EntityCommand cmd = conn.CreateCommand())

 

08 {

 

09 cmd.CommandText = esqlQuery;

 

10 using (EntityDataReader rdr = cmd.ExecuteReader())

 

11 {

 

12 while (rdr.Read())

 

13 {

 

14

 

15 }

 

16 }

 

17 }

 

18 conn.Close();

 

19 }

 

You need to ensure that the code returns a reference to a ComplexType entity in the model named EmailPhone.

 

Which code segment should you insert at line 14?

 

A.

int FldIdx = 0;

EntityKey key = record.GetValue(FldIdx) as EntityKey;

foreach (EntityKeyMember keyMember in key.EntityKeyValues)

{

return keyMember.Key + ” : ” + keyMember.Value;

}

B.

IExtendedDataRecord record = rdr[“EmailPhone”]as IExtendedDataRecord; int FldIdx = 0;

return record.GetValue(FldIdx);

C.

DbDataRecord nestedRecord = rdr[“EmailPhoneComplexProperty”] as DbDataRecord; return nestedRecord;

D.

int fieldCount = rdr[“EmailPhone”].DataRecordInfo.FieldMetadata.Count;

for (int FldIdx = 0; FldIdx < fieldCount; FldIdx++)

{

rdr.GetName(FldIdx); if (rdr.IsDBNull(FldIdx) == false)

{

return rdr[“EmailPhone”].GetValue(FldIdx).ToString();

}

}

 

Correct Answer: C

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…