Ensurepass

QUESTION 111

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. You define a Category class by writing the following code segment. (Line numbers are included for reference only.)

 

01 public class Category

02 {

03 public int CategoryID { get; set; }

04 public string CategoryName { get; set; }

05 public string Description { get; set; }

06 public byte[] Picture { get; set; }

07 …

08 }

 

You need to add a collection named Products to the Category class. You also need to ensure that the collection supports deferred loading. Which code segment should you insert at line 07?

 

  1. public static List <Product> Products { get; set; }

  2. public virtual List <Product> Products { get; set; }

  3. public abstract List <Product> Products { get; set; }

  4. protected List <Product> Products { get; set; }

 

Correct Answer: B

 

 

QUESTION 112

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows Forms application. You plan to deploy the application to several shared client computers. You write the following code segment.

(Line numbers are included for reference only.)

 

01 Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

02 …

03 config.Save();

04 …

 

You need to encrypt the connection string stored in the .config file. Which code segment should you insert at line 02?

 

  1. ConnectionStringsSection section = config.GetSection(“connectionString”) as ConnectionStringsSection; section.SectionInformation.ProtectSection(“DataProtectionConfigurationProvider”);

 

  1. ConnectionStringsSection section = config.GetSection(“connectionStrings”) as ConnectionStringsSection; section.SectionInformation.ProtectSection(“DataProtectionConfigurationProvider”);

 

  1. ConnectionStringsSection section = config.GetSection(“connectionString”) as ConnectionStringsSection; section.SectionInformation.ProtectSection(“RsaProtectedConfigurationProvider”);

 

  1. ConnectionStringsSection section = config.GetSection(“connectionStrings”) as ConnectionStringsSection; section.SectionInformation.ProtectSection(“RsaProtectedConfigurationProvider”);

 

Correct Answer: D

 

 

QUESTION 113

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 Entity Framework to model entities. The database includes objects based on the exhibit. The application includes the following code segment. (Line numbers are included for reference only.)

 

01 using (AdventureWorksEntities context = new AdventureWorksEntities()){

02 …

03 foreach (SalesOrderHeader order in customer.SalesOrderHeader){

04 Console.WriteLine(String.Format(“Order: {0} “, order.SalesOrderNumber));

05 foreach (SalesOrderDetail item in order.SalesOrderDetail){

06 Console.WriteLine(String.Format(“Quantity: {0} “, item.Quantity));

07 Console.WriteLine(String.Format(“Product: {0} “, item.Product.Name));

08 }

09 }

10 }

 

You want to list all the orders for a specified customer. You need to ensure that the list contains the following fields:

 

  • Order number

  • Quantity of products

  • Product name

 

Which code segment should you insert at line 02?

 

  1. Contact customer = context.Contact.Where(“it.ContactID = @customerId”, new ObjectParameter

(“@customerId”, customerId)).First();

 

  1. Contact customer = context.Contact.Where(“it.ContactID = @customerId”, new ObjectParameter

(“customerId”, customerId)).First();

 

  1. context.ContextOptions.LazyLoadingEnabled = true;

Contact customer = (from contact in context.Contact

include(“SalesOrderHeader.SalesOrderDetail”)

select conatct).FirstOrDefault();

 

  1. Contact customer = (from contact in context.Contact

include(“SalesOrderHeader”)

select conatct).FirstOrDefault();

 

Correct Answer: B

 

 

QUESTION 114

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. You write the following code segment. (Line numbers are included for reference only.)

 

01 AdventureWorksEntities context = new AdventureWorksEntities(“http://localhost:1234/AdventureWorks.svc”);

02 …

03 var q = from c in context.Customers

04 where c.City == “London”

05 orderby c.CompanyName

06 select c;

 

You need to ensure that the application meets the following requirements:

 

  • Compares the current values of unmodified properties with values returned from the data source.

  • Marks the property as modified when the properties are not the same.

 

Which code segment should you insert at line 02?

 

  1. context.MergeOption = MergeOption.AppendOnly;

  2. context.MergeOption = MergeOption.PreserveChanges;

  3. context.MergeOption = MergeOption.OverwriteChanges;

  4. context.MergeOption = MergeOption.NoTracking;

 

Correct Answer: B

 

 

QUESTION 115

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. You write the following code segment. (Line numbers are included for reference only.)

 

01 public partial class SalesOrderDetail : EntityObject

02 {

03 partial void OnOrderQtyChanging(short value)

04 {

05 …

06 {

07 …

08 }

09 }

10 }

 

You need to find out whether the object has a valid ObjectStateEntry instance. Which code segment should you insert at line 05?

 

  1. if (this.EntityState != EntityState.Detached)

  2. if (this.EntityState != EntityState.Unchanged)

  3. if (this.EntityState != EntityState.Modified)

  4. if (this.EntityState != EntityState.Added)

 

Correct Answer: D

 

 

QUESTION 116

You use Microsoft Visual Studio 2010, Microsoft Sync Framework, and Microsoft .NET Framework 4.0 to create an application. You have a ServerSyncProvider connected to a Microsoft SQL Server database. The database is hosted on a Web server. Users will use the Internet to access the Customer database through the ServerSyncProvider. You write the following code segment. (Line numbers are included for reference only.)

 

01 SyncTable customerSyncTable = new SyncTable(“Customer”);

02 customerSyncTable.CreationOption = TableCreationOption.UploadExistingOrCreateNewTable;

03 …

04 customerSyncTable.SyncGroup = customerSyncGroup;

05 this.Configuration.SyncTables.Add(customerSyncTable);

 

You need to ensure that the application meets the following requirements: Users can modify data locally and receive changes from the server. Only changed rows are transferred during synchronization. Which code segment should you insert at line 03?

 

  1. customerSyncTable.SyncDirection = SyncDirection.DownloadOnly;

  2. customerSyncTable.SyncDirection = SyncDirection.Snapshot;

  3. customerSyncTable.SyncDirection = SyncDirection.Bidirectional;

  4. customerSyncTable.SyncDirection = SyncDirection.UploadOnly;

 

Correct Answer: C

 

 

QUESTION 117

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows Communication Foundation (WCF) Data Services service. The service connects to a Microsoft SQL Server 2008 database. The service is hosted by an Internet Information Services (IIS) 6.0 Web server. The application works correctly in the development environment. However, when you connect to the service on the production server, attempting to update or delete an entity results in an error. You need to ensure that you can update and delete entities on the production server. What should you do?

 

  1. Add the following line of code to the InitializeService method of the service:

config.SetEntitySetAccessRule (“*”, EntitySetRights.WriteDelete | EntitySetRights.WriteInsert);

  1. Add the following line of code to the InitializeService method of the service:

config.SetEntitySetAccessRule (“*”, EntitySetRights.WriteDelete | EntitySetRights.WriteMerge);

  1. Configure IIS to allow the PUT and DELETE verbs for the .svc Application Extension.

  2. Configure IIS to allow the POST and DELETE verbs for the .svc Application Extension.

 

Correct Answer: C

 

 

QUESTION 118

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. The database includes a table named dbo. Documents that contains a column with large binary data. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)

 

01 public void LoadDocuments(DbConnection cnx)

02 {

03 var cmd = cnx.CreateCommand();

04 cmd.CommandText = “SELECT * FROM dbo.Documents”;

05 …

06 cnx.Open();

07 …

08 ReadDocument(reader);

09 }

 

You need to ensure that data can be read as a stream. Which code segment should you insert at line 07?

 

  1. var reader = cmd.ExecuteReader(CommandBehavior.Default);

  2. var reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);

  3. var reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);

  4. var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);

 

Correct Answer: D

 

 

QUESTION 119

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 create a DataSet object in the application. You add two DataTable objects named App_Products and App_Categories to the DataSet. You add the following code segment to populate the DataSet object. (Line numbers are included for reference only.)

 

01 public void Fill(SqlConnection cnx, DataSet ds)

02 {

03 var cmd = cnx.CreateCommand();

04 cmd.CommandText = “SELECT * FROM dbo.Products; ” + “SELECT * FROM dbo.Categories”;

05 var adapter = new SqlDataAdapter(cmd);

06 …

07 }

 

You need to ensure that App_Products and App_Categories are populated from the dbo.Products and dbo.Categories database tables. Which code segment should you insert at line 06?

 

  1. adapter.Fill(ds, “Products”);

adapter.Fill(ds, “Categories”);

 

  1. adapter.Fill(ds.Tables[“App_Products”]);

adapter.Fill(ds.Tables[“App_Categories”]);

 

  1. adapter.TableMappings.Add(“Table”, “App_Products”);

adapter.TableMappings.Add(“Table1”, “App_Categories”);

adapter.Fill(ds);

 

  1. adapter.TableMappings.Add(“Products”, “App_Products”);

adapter.TableMappings.Add(“Categories”, “App_Categories”);

adapter.Fill(ds);

 

Correct Answer: D

 

 

QUESTION 120

You are calling a stored procedure in SQL Server 2008 that returns a UDT as an output parameter. This UDT, called MyCompanyType, was created by your company. The UDT has a method called GetDetails that you want to execute in your client application. What must you do to execute the method? (Each correct answer presents part of a complete solution. Choose three.)

 

  1. Set the SqlDbType of the parameter to SqlDbType.Udt.

  2. Set the UdtTypeName of the parameter to MyCompanyType.

  3. Call the ExecuteXmlReader method on the SqlCommand to serialize the UDT as XML.

  4. In the client application, set a reference to the assembly in which the UDT is
    .

 

Correct Answer: ABD

 

 

Instant Access to Download Latest Complete Collection of Microsoft MCTS 70-516 Real Exam

Try Microsoft MCTS 70-516 Free Demo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.