Searching for "(Line"

Q:

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


01AdventureWorksEntities context = New AdventureWorksEntities
02
03var q = from c in context.Customers
04where c.City == "London"
05orderby c.CompanyName
06select 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?

A) context.MergeOption = MergeOption.AppendOnly; B) context.MergeOption = MergeOption.PreserveChanges;
C) context.MergeOption = MergeOption.OverwriteChanges; D) context.MergeOption = MergeOption.NoTracking;
 
Answer & Explanation Answer: B) context.MergeOption = MergeOption.PreserveChanges;

Explanation:
Report Error

View Answer Report Error Discuss

Q:

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.)


01DataSet customerOrders = new DataSet();
02customerOrders.EnforceConstraints = true;
03ForeignKeyConstraint ordersFK = new ForeignKeyConstraint("ordersFK",
04customerOrders.Tables["Customers"].Columns["CustomerID"],
05customerOrders.Tables["Orders"].Columns["CustomerID"]);
06
07customerOrders.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.SetNull; B) ordersFK.DeleteRule = Rule.None;
C) ordersFK.DeleteRule = Rule.SetDefault; D) ordersFK.DeleteRule = Rule.Cascade;
 
Answer & Explanation Answer: B) ordersFK.DeleteRule = Rule.None;

Explanation:
Report Error

View Answer Report Error Discuss

Q:

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


01public void LoadDocuments(DbConnection cnx)
02{
03var cmd = cnx.CreateCommand();
04cmd.CommandText = "SELECT * FROM dbo.Documents";
05...
06cnx.Open();
07
08ReadDocument(reader); }


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

A) var reader = cmd.ExecuteReader(CommandBehavior.Default); B) var reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
C) var reader = cmd.ExecuteReader(CommandBehavior.KeyInfo); D) var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
 
Answer & Explanation Answer: D) var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);

Explanation:
Report Error

View Answer Report Error Discuss