This page was exported from All The Latest MCTS Exam Questions And Answers For Free Share [ https://www.mctsdump.com ] Export date:Thu Nov 21 11:35:57 2024 / +0000 GMT ___________________________________________________ Title: [Pass Ensure VCE Dumps] Valid 286q 70-516 Practice Test with Free PDF Study Guide Download (201-220) --------------------------------------------------- How to pass 70-516 exam at the first time? PassLeader now is offering the free new version of 70-516 exam dumps. The new 286q 70-516 exam questions cover all the new added questions, which will help you to get well prepared for the exam 70-516, our premium 70-516 PDF dumps and VCE dumps are the best study materials for preparing the 70-516 exam. Come to passleader.com to get the valid 286q 70-516 braindumps with free version VCE Player, you will get success in the real 70-516 exam for your first try. 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 201You 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 load records from the Customers table into a DataSet object named dataset. You need to retrieve the value of the City field from the first and last records in the Customers table. Which code segment should you use? A.    DataTable dt = dataset.Tables["Customers"]; string first = dt.Rows[0]["City"].ToString(); string last = dt.Rows[dt.Rows.Count - 1]["City"].ToString();B.    DataTable dt = dataset.Tables["Customers"];string first = dt.Rows[0]["City"].ToString();string last = dt.Rows[dt.Rows.Count]["City"].ToString();C.    DataRelation relationFirst = dataset.Relations[0];DataRelation relationLast = dataset.Relations[dataset.Relations.Count - 1];string first = relationFirst.childTable.Columns["City"].ToString();string last = relationLast.childTable.Columns["City"].ToString()D.    DataRelation relationFirst = dataset.Relations[0];DataRelation relationLast = dataset.Relations[dataset.Relations.Count];string first = relationFirst.childTable.Columns["City"].ToString();string last = relationLast.childTable.Columns["City"].ToString(); Answer: A QUESTION 202You 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 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; Answer: BExplanation: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 ClassesLesson 1: Working with the DataTable and DataSet Classes Cascading Deletes and Cascading Updates (page 26) QUESTION 203You 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 a DataTable named OrderDetailTable that has the following columns: - ID - OrderID - ProductID - Quantity - LineTotal Some records contain a null value in the LineTotal field and 0 in the Quantity field. You write the following code segment. (Line numbers are included for reference only.) 01 DataColumn column = new DataColumn("UnitPrice", typeof(double)); 02 ...03 OrderDetailTable.Columns.Add(column); You need to add a calculated DataColumn named UnitPrice to the OrderDetailTable object. You also need to ensure that UnitPrice is set to 0 when it cannot be calculated. Which code segment should you insert at line 02? A.    column.Expression = "LineTotal/Quantity";B.    column.Expression = "LineTotal/ISNULL(Quantity, 1)";C.    column.Expression = "if(Quantity > 0, LineTotal/Quantity, 0)";D.    column.Expression = "iif(Quantity > 0, LineTotal/Quantity, 0)"; Answer: DExplanation:IIF ( boolean_expression, true_value, false_value ) QUESTION 204You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database and contains a LINQ to SQL data model. The data model contains a function named createCustomer that calls a stored procedure. The stored procedure is also named createCustomer. The createCustomer function has the following signature. createCustomer (Guid customerID, String customerName, String address1) The application contains the following code segment. (Line numbers are included for reference only.)01 CustomDataContext context = new CustomDataContext(); 02 Guid userID = Guid.NewGuid();03 String address1 = "1 Main Steet"; 04 String name = "Marc";05 ...You need to use the createCustomer stored procedure to add a customer to the database. Which code segment should you insert at line 05? A.    context.createCustomer(userID, customer1, address1);B.    context.ExecuteCommand("createCustomer", userID, customer1, address1);Customer customer = new Customer() { ID = userID, Address1 = address1, Name = customer1, };C.    context.ExecuteCommand("createCustomer", customer);Customer customer = new Customer() { ID = userID, Address1 = address1, Name = customer1, };D.    context.ExecuteQuery(typeof(Customer), "createCustomer", customer); Answer: A QUESTION 205You 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 manage persistence-ignorant entities. You create an ObjectContext instance named context. Then, you directly modify properties on several entities. You need to save the modified entity values to the database. Which code segment should you use? A.    context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);B.    context.SaveChanges(SaveOptions.DetectChangesBeforeSave);C.    context.SaveChanges(SaveOptions.None);D.    context.SaveChanges(); Answer: BExplanation:None Changes are saved without the DetectChanges or the AcceptAllChangesAfterSave() methods being called.AcceptAllChangesAfterSave After changes are saved, the AcceptAllChangesAfterSave() method is called, which resets change tracking in the ObjectStateManager.DetectChangesBeforeSave Before changes are saved, the DetectChanges method is called to synchronize the property values of objects that are attached to the object context with data in the ObjectStateManager.SaveOptions Enumerationhttp://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions.aspx QUESTION 206You develop a Microsoft .NET application that uses Entity Framework to store entities in a Microsft SQL Server 2008 database. While the application is disconnected from the database, entities that are modified, are serialized to a local file. The next time the application connects to the database, it retrieves the identity from the database by using an object context named context and stores the entity in a variable named remoteCustomer. The application then serializes 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 is 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", remoteCustomer);D.    context.ApplyCurrentValues("Customers", localCustomer); Answer: DExplanation:Reference:http://msdn.microsoft.com/en-us/library/dd487246.aspx QUESTION 207You use Microsoft .NET framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database named AdventureWorksLT. The database resides on an instance named INSTA on a server named SQL01. You need to configure the application to connect to the database. Which connection string should you add to the .config file? A.    Data Source=SQL01; Initial Catalog=INSTA; Integrated Security=true; Application Name=AdventureWorksLT;B.    Data Source=SQL01; Initial Catalog=AdventureWorksLT; Integrated Security=true; Application Name=INSTA;C.    Data Source=SQL01INSTA; Initial Catalog=AdventureWorksLT; Integrated Security=true;D.    Data Source=AdventureWorksLT; Initial Catalog=SQL01INSTA; Integrated Security=true; Answer: C QUESTION 208You 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 (click the Exhibit button). The application includes the following code segment. (Line numbers are included for reference only.)01 using(AdventureWorksEntities context = new AdventureWorksEntities())02 {03    ...04    foreach (SalesOrderHeader order in customer.SalesOrderHeader)05    {06        Console.WriteLine(String.Format("Order: {0} ", order.SalesOrderNumber));07        foreach (SalesOrderDetail item in order.SalesOrderDetail)08        {09           Console.WriteLine(String.Format("Quantity: {0} ", item.Quantity));10           Console.WriteLine(String.Format("Product: {0} ", item.Product.Name));11        }12    }13 }You want to list all the orders for a specific customer. You need to ensure that the list contains following fields:- Order number- Quantity of products- Product nameWhich code segment should you insert in line 03? A.    Contact customer = context.Contact.Where("it.ContactID = @customerId", new ObjectParameter("customerId", customerId)).First();B.    Contact customer = context.Contact.Where("it.ContactID = @customerId", new ObjectParameter("@customerId", customerId)).First();C.    Contact customer = (from contact in context.Contact.Include("SalesOrderHeader.SalesOrderDetail")select contact).FirstOrDefault();D.    Contact customer = (from contact in context.Contact.Include("SalesOrderHeader")select contact).FirstOrDefault(); Answer: A QUESTION 209You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. You are creating the data layer of the application. You write the following code segment. (Line numbers are included for reference only.)01 public static SqlDataReader GetDataReader(string sql)02 {03    SqlDataReader dr = null;04    ...05    return dr;06 }You need to ensure that the following requirements are met:- The SqlDataReader returned by the GetDataReader method can be used to retreive rows from the database.- SQL connections opened within the GetDataReader method will close when the SqlDataReader is closed.Which code segment should you insert at the line 04? A.    using(SqlConnection cnn = new SqlConnection(strCnn)){try{SqlCommand cmd = new SqlCommand(sql, cnn);cnn.Open();dr = cmd.ExecuteReader();}catch{ throw;}}B.    SqlConnection cnn = new SqlConnection(strCnn);SqlCommand cmd = new SqlCommand(sql, cnn);cnn.Open();{try{dr = cmd.ExecuteReader();}finally{ cnn.Close();}}C.    SqlConnection cnn = new SqlConnection(strCnn);SqlCommand cmd = new SqlCommand(sql, cnn);cnn.Open();{try{dr = cmd.ExecuteReader();cnn.Close();}catch{ throw;}}D.    SqlConnection cnn = new SqlConnection(strCnn);SqlCommand cmd = new SqlCommand(sql, cnn);cnn.Open();{try{dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);}catch{ cnn.Close();throw;}} Answer: DExplanation:CommandBehavior.CloseConnection When the command is executed, the associated Connection object is closed when the associated DataReader object is closed.CommandBehavior Enumerationhttp://msdn.microsoft.com/en-us/library/system.data.commandbehavior.aspxSqlCommand.ExecuteReader Method (CommandBehavior)http://msdn.microsoft.com/en-us/library/y6wy5a0f.aspx QUESTION 210You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework. The application has an entity model that includes SalesTerritory and SalesPerson entities as shown in the following diagram. You need to calculate the total bonus for all sales people in each sales territory. Which code segment should you use? A.    from person in model.SalesPersonsgroup person by person.SalesTerritoryinto territoryByPersonselect new{   SalesTerritory = territoryByPerson.Key,    TotalBonus = territoryByPerson.Sum(person => person.Bonus)};B.    from territory in model.SalesTerritoriesgroup territory by territory.SalesPersoninto personByTerritoriesselect new {   SalesTerritory = personByTerritories.Key,   TotalBonus = personByTerritories.Key.Sum(person => person.Bonus)};C.    model.SalesPersons.GroupBy(person => person.SalesTerritory).SelectMany(group => group.Key.SalesPersons).Sum(person => person.Bonus);D.    model.SalesTerritories.GroupBy(territory => territory.SalesPersons).SelectMany(group => group.Key).Sum(person => person.Bonus); Answer: A http://www.passleader.com/70-516.html QUESTION 211You 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 add the following store procedure to the database.CREATE PROCEDURE GetSalesPeopleASBEGINSELECT FirstName, LastName, Suffix, Email, PhoneFROM SalesPeopleENDYou write the following code segment. (Line numbers are included for reference only.)01 SqlConnection connection = new SqlConnection("...");02 SqlCommand command = new SqlCommand("GetSalesPeople", connection);03 command.CommandType = CommandType.StoredProcedure;04 ...You need to retreive all of the results from the stored procedure. Which code segment should you insert at line 04? A.    var res = command.ExecuteReader();B.    var res = command.ExecuteScalar();C.    var res = command.ExecuteNonQuery();D.    var res = command.ExecuteXmlReader(); Answer: AExplanation:ExecuteReader Sends the CommandText to the Connection and builds a SqlDataReader.SqlCommand Classhttp://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx QUESTION 212The Entity Data Model file (.edmx file) must be updated to support inheritance mapping for Products and Componets. You need to add the following code to the ModelModel.edmx file:- the code in line EX243 that maps the Product type- the code in line EX250 that maps the Component typeWhat should you do? A.    Insert the following code at line EX243:<Condition ColumnName="ProductType" IsNull="false" />Insert the following code at line EX250:<Condition ColumnName="PartType" IsNull="false" />B.    Insert the following code at line EX243:<Condition ColumnName="ProductType" IsNull="true" />Insert the following code at line EX250:<Condition ColumnName="PartType" IsNull="true" />C.    Insert the following code at line EX243:<Condition ColumnName="ProductType" IsNull="false" />Insert the following code at line EX250:<Condition ColumnName="PartType" IsNull="true" />D.    Insert the following code at line EX243:<Condition ColumnName="ProductType" IsNull="true" />Insert the following code at line EX250:<Condition ColumnName="PartType" IsNull="false" /> Answer: A QUESTION 213A performance issue exists in the application. The following code segment is causing a performance bottleneck:var colors = context.Parts.GetColors();You need to improve application performance by reducing the number of database calls. Which code segment should you use? A.    var colors = context.Parts.OfType<Product>().Include("Colors").GetColors();B.    var colors = context.Parts.OfType<Product>().Include("Product.Color").GetColors();C.    var colors = context.Parts.OfType<Product>().Include("Parts.Color").GetColors();D.    var colors = context.Parts.OfType<Product>().Include("Color").GetColors(); Answer: D QUESTION 214The application must be configured to run on a new development computer. You need to configure the connection string to point to the existing named instance. Which connection string fragment should you use? A.    Data Source=INST01SQL01B.    Initial Catalog= SQL01INST01C.    Data Source=SQL01INST01D.    Initial Catalog= INST01SQL01 Answer: C QUESTION 215You have an existing ContosoEntities context object named context. Calling the SaveChanges() method on the context object generates an exception that has the following inner exception:System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.Colors' with unique index 'IX_Colors'.You need to ensure that a call to SaveChanges() on the context object does not generate this exception. What should you do? A.    Examine the code to see how Color objects are allocated. Replace any instance of the new Color() method with a call to the ContosoEntities.LoadOrCreate() method.B.    Add a try/catch statement around every call to the SaveChanges() method.C.    Remove the unique constraint on the Name column in the Colors table.D.    Override the SaveChanges() method on the ContosoEntities class, call the ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added) method, and call the AcceptChanges() method on each ObjectStateEntry object it returns Answer: A QUESTION 216Refer to the following lines in the case study:PA40 in ModelPart.cs, PR16 inModelProduct.cs, and CT14 in ModelComponent.csThe application must create XML files that detail the part structure for any product. The XML files must use the following format:<?xml version="1.0" encoding="utf-8"?><product name="Brush" description="Brush product" productType="1"><component name="Handle" description="Handle" partType="2"><component name="Screw" description="Screw" partType="3"><component name="Wood"  description="Wooden shaft" partType="45"></component><component name="Head" description="Head" partType="5"><component name="Screw" description="Screw" partType="3"><component name="Bristles"  description="Bristles" partType="4"></component></product>You need to update the application to support the creation of an XElement object having a structure that will serialize to the format shown above. What should you do? (Each correct answer presents part of the solution. Choose two.) A.    Insert the following code segment at line PR16 in ModelProduct.cs:return new XElement("product, new XAttribute("name", this.Name), new XElement("description", this.Description), new XElement("productType", this.ProductType));B.    Insert the following code segment at line CT14 in ModelComponent.cs:return new XElement("component, new XElement("name", this.Name), new XElement("description", this.Description), new XElement("partType", this.PartType));C.    Insert the following code segment at line PR16 in ModelProduct.cs:return new XElement("product, new XElement("name", this.Name), new XElement("description", this.Description), new XElement("productType", this.ProductType));D.    Insert the following code segment at line PR16 in ModelProduct.cs:return new XElement("product, new XAttribute("name", this.Name), new XAttribute("description", this.Description), new XAttribute("productType", this.ProductType));E.    Insert the following code segment at line CT14 in ModelComponent.cs:return new XElement("component, new XAttribute("name", this.Name), new XElement("description", this.Description), new XElement("partType", this.PartType));F.    Insert the following code segment at line CT14 in ModelComponent.cs:return new XElement("component, new XAttribute("name", this.Name), new XAttribute("description", this.Description), new XAttribute("partType", this.PartType)); Answer: DF QUESTION 217You need to ensure that an exception is thrown when color names are set to less than two characters. What should you do? A.    Add the following method to the Color partial class in ModelColor.cs:protected overrride void OnPropertyChanged(string property){if (property == "Name" && this.Name.Length < 2)throw new ArgumentOutOfRangeException("Name must be at least two characters");}B.    Add the following code segment to the ContosoEntities partial class in ModelContosoEntities.cs:public override in SaveChanges(System.Data.Objects.SaveOptions options){var changes = this.ObjectStateManager.GetObjectSateEntries(System.Data.EntityState.Added);foreach (var change in changes){if (change.Entity is Color)if (((Color)change.Entity.Name.Length < 2) throw new ArgumentException("Name too short");}return base.SaveChanges(options);}C.    Add the following attribute to the Name property of the Color class in the entity designer file:[StringLength(256, MinimumLength = 2)]D.    Add the following method to the Color partial class in ModelColor.cs:protected overrride void OnPropertyChanging(string property){if (property == "Name" && this.Name.Length < 2)throw new ArgumentOutOfRangeException("Name must be at least two characters");} Answer: A QUESTION 218Drag and Drop QuestionYou are developing an application that updates entries in a Microsoft SQL Server table named Orders. You need to ensure that you can update the rows in the Orders table by using optimistic concurrency. What code should you use? (To answer, drag the appropriate properties to the correct locations. Each property 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.) Answer: QUESTION 219You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. The appl cat on 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.    Option AB.    Option BC.    Option CD.    Option D Answer: D QUESTION 220You are developing a Microsoft .NET Framework 4 application. You need to collect performance data to the event log after the application is deployed to the production environment. Which two components should you include in the project? (Each correct answer presents part of the solution. Choose two.) A.    A trace listenerB.    A debug listenerC.    Debug.Asset() statementsD.    Debug.WriteLine() statementsE.    Trace.WriteLine() statements Answer: BC http://www.passleader.com/70-516.html --------------------------------------------------- Images: --------------------------------------------------- --------------------------------------------------- Post date: 2015-12-22 03:16:01 Post date GMT: 2015-12-22 03:16:01 Post modified date: 2015-12-22 03:16:01 Post modified date GMT: 2015-12-22 03:16:01 ____________________________________________________________________________________________ Export of Post and Page as text file has been powered by [ Universal Post Manager ] plugin from www.gconverters.com