[Free] New Updated (October) Microsoft 70-516 Real Exam 121-130

Ensurepass

 

QUESTION 121

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. The application performs a database query within a transaction.

 

You need to ensure that the application can read data that has not yet been committed by other transactions.

 

Which IsolationLevel should you use?

 

A.

ReadUncommitted

B.

ReadCommitted

C.

RepeatableRead

D.

Unspecified

 

Correct Answer: A

Explanation:

Unspecified A different isolation level than the one specified is being used, but the level cannot be determined.

When using OdbcTransaction, if you do not set IsolationLevel or you set IsolationLevel to Unspecified, the transaction executes according to the isolation level that is determined by the driver that is being used.

Chaos The pending changes from more highly isolated transactions cannot be overwritten. ReadUncommitted A dirty read is possible, meaning that no shared locks are issued and no exclusive locks are honored.

ReadCommitted Shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.

RepeatableRead Locks are placed on all data that is used in a query, preventing other users from updating the data.

Prevents non-repeatable reads but phantom rows are still possible. Serializable A range lock is placed on the DataSet, preventing other users from updating or inserting rows into the dataset until the transaction is complete. Snapshot Reduces blocking by storing a version of data that one application can read while another is modifying the same data.

Indicates that from one transaction you cannot see changes made in other transactions, even if you requery.

IsolationLevel Enumeration

http://msdn.microsoft.com/en-us/library/system.data.isolationlevel.aspx

Isolation Levels in Database Engine

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

SET TRANSACTION ISOLATION LEVEL (Transact-SQL)

http://msdn.microsoft.com/ru-ru/library/ms173763.aspx

 

 

QUESTION 122

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application uses the ADO.NET Entity Framework to manage customer and related order records.

 

You add a new order for an existing customer.

 

You need to associate the Order entity with the Customer entity.

 

What should you do?

 

A.

Set the Value property of the EntityReference of the Order entity.

B.

Call the Add method on the EntityCollection of the Order entity.

C.

Use the AddObject method of the ObjectContext to add both Order and Customer entities.

D.

Use the Attach method of the ObjectContext to add both Order and Customer entities.

 

Correct Answer: A

Explanation:

Entity Reference (Of Entity) Represents a related end of an association with a multiplicity of zero or one.

 

 

QUESTION 123

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 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 co

lumn = 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/Qua

ntity, 0)”;

 

Correct Answer: D

Explanation:

IIF ( boolean_expression, true_value, false_value )

 

 

QUESTION 124

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. You use the ADO.NET Entity Framework Designer to model entities. You add the following stored procedure to the database, and you add a function import to the model.

 

CREATE PROCEDURE [dbo].[InsertDepartment]

 

@Name nvarchar(50),

 

@ ID int NULL OUTPUT

 

AS

 

INSERT INTO Department (Name) VALUES (@Name)

 

SELECT @ID = SCOPE_IDENTITY()

 

You need to insert a new department and display the generated ID.

 

Which code segment should you use?

 

A.

using (SchoolEntities context = new SchoolEntities()) {

var id = new ObjectParameter(“ID”, typeof(int));

context.InsertDepartment(“Department 1”, id);

Console.WriteLine(id.Value);

}

B.

using (SchoolEntities context = new SchoolEntities())

{

var id = context.InsertDepartment(“Department 1”, null);

Console.WriteLine(id) ;

}

C.

using (SchoolEntities context new SchoolEntities())

{

CtojectParameter id = null;

context.InsertDepartment(“Department 1”, id);

Console.WriteLine(id.Value);

}

D.

using (SchoolEntities context = new SchoolEntities())

{

var id = new OtajectParameter(“ID”, null));

context.InsertDepartment(“Department 1”, id);

Console.WriteLlne(id.Value);

}

 

Correct Answer: A

Explanation:

http://blogs.microsoft.co.il/blogs/gilf/archive/2010/05/09/how-to-retrieve-stored-procedure-output-parametersin-entity-framework.aspx

 

 

QUESTION 125

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database.

 

You add the following stored procedure to the database.

 

CREATE PROCEDURE GetProducts

 

AS

 

BEGIN

 

SELECT ProductID, Name, Price, Cost

 

FROM Product

 

END

 

You create a SqlDataAdapter named adapter to execute the stored procedure.

 

You need to fill a DataTable instance with the first 10 rows of the result set.

 

What are two possible code segments that you can use to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

DataSet ds = new DataSet();

adapter.Fill(ds, 0, 10, “Product”)

B.

DataSet ds = new DataSet();

DataTable dt = ds.Tables.Add(“Product”);

adapter.Fill(0, 10, dt);

C.

DataSet ds = new DataSet();

DataTable dt = ds.Tables.Add(“Product”);

dt.ExtendedProperties[“RowCount”] = 10;

dt.ExtendedProperties[“RowIndex”] = 0;

adapter.Fill(dt);

D.

DataSet ds = new DataSet();

ds.ExtendedProperties[“RowCount”] = 10;

ds.ExtendedProperties[“RowIndex”] = 0;

adapter.Fill(ds);

 

Correct Answer: AB

Explanation:

Fill(Int32, Int32, DataTable()) Adds or refreshes rows in a DataTable to match those in the data source starting at the specified record and retrieving up to the specified maximum number of records. (Inherited from DbDataAdapter.)

Fill(DataSet, Int32, Int32, String) Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names. (Inherited from DbDataAdapter.)

SqlDataAdapter Class

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx

DataTable.ExtendedProperties Gets the collection of customized user information.

QUESTION 126

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. You deploy an application to a production server. The application uses the model and mapping files that are deployed as application resources.

 

You need to update the conceptual model for the application on the production server.

 

What should you do?

 

A.

Copy the updated .edmx file to the production server.

B.

Copy the updated .csdl file to the production server.

C.

Copy the updated .ssdl file to the production server.

D.

Recompile the application and redeploy the modified assembly file.

 

Correct Answer: D

 

 

QUESTION 127

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 application contains two SqlCommand objects named cmd1 and cmd2.

 

You need to measure the time required to execute each command.

 

Which code segment should you use?

 

A.

Stopwatch w1 = new Stopwatch();

w1.Start();

cmd1.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

w1.Start();

cmd2.ExecuteNonQuery();

w1.Stop();

Trac

e.WriteLine(w1.ElapsedMilliseconds);

B.

Stopwatch w1 = new Stopwatch();

w1.Start();

cmd1.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

w1.Reset();

cmd2.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

C.

Stopwatch w1 = Stopwatch.StartNew();

cmd1.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

w1.Start();

cmd2.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

D.

Stopwatch w1 = Stopwatch.StartNew();

cmd1.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

w1 = Stopwatch.StartNew();

cmd2.ExecuteNonQuery();

w1.Stop();

Trace.WriteLine(w1.ElapsedMilliseconds);

 

Correct Answer: D

Explanation:

A & C do not reset the stopwatch before running cmd2. B does not start the stopwatch after resetting the stopwatch Start() does not reset the stopwatch, whereas StartNew() will create a new instance of the Stop watch and initialise the elapsed time to Zero.

Stopwatch Class

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

 

 

QUESTION 128

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 use the ADO.NET LINQ to SQL model to retrieve data from the database.

 

The application contains the Category and Product entities, as shown in the following exhibit.

 

clip_image001

 

You need to ensure that LINQ to SQL executes only a single SQL statement against the database.

 

You also need to ensure that the query retrieves the list of categories and the list of products.

 

Which code segment should you use?

 

A.

using (NorthwindDataContext dc = new NorthwindDataContext()) {

dc.ObjectTrackingEnabled = false;

var categories = from c in dc.Categories

select c;

foreach (var category in categories)

{

Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);

}

}

B.

using (NorthwindDataContext dc = new NorthwindDataContext()) {

dc.DeferredLoadingEnabled = false;

DataLoadOptions dlOptions = new DataLoadOptions();

dlOptions.LoadWith<Category>(c => c.Products);

dc.LoadOptions = dlOptions;

var categories = from c in dc.Categories

select c;

foreach (var category in categories)

{

Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);

}

}

C.

using (NorthwindDataContext dc = new NorthwindDataContext()) {

dc.DeferredLoadingEnabled = false;

var categories = from c in dc.Categories

select c;

foreach (var category in categories)

{

Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);

}

}

D.

using (NorthwindDataContext dc = new NorthwindDataContext()) {

dc.DeferredLoadingEnabled = false;

DataLoadOptions dlOptions = new DataLoadOptions();

dlOptions.AssociateWith<Category>(c => c.Products);

dc.LoadOptions = dlOptions;

var categories = from c in dc.Categories

select c;

foreach (var category in categories)

{

Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);

}

}

 

Correct Answer: B

Explanation:

DataLoadOptions Class Provides for immediate loading and filtering of related data. DataLoadOptions.LoadWith(LambdaExpression) Retrieves specified data related to the main target by using a lambda expression.

You can retrieve many objects in one query by using LoadWith. DataLoadOptions.AssociateWith(LambdaExpression) Filters the objects retrieved for a particular relationship.

Use the AssociateWith method to specify sub-queries to limit the amount of retrieved data.

DataLoadOptions Class

http://msdn.microsoft.com/en-us/library/system.data.linq.dataloadoptions.aspx

How to: Retriev

e Many Objects At Once (LINQ to SQL)

http://msdn.microsoft.com/en-us/library/Bb386917(v=vs.90).aspx

How to: Filter Related Data (LINQ to SQL)

http://msdn.microsoft.com/en-us/library/Bb882678(v=vs.100).aspx

 

 

 

 

QUESTION 129

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 have a stored procedure that updates data in the database.

 

You need to ensure that if the connection to the database fails, any data already written to the database is rolled back.

 

What should you use?

 

A.

Advanced Data Connector (ADC)

B.

Microsoft Message Queuing (MSMQ)

C.

Lightweight Transaction Manager (LTM)

D.

Remote Data Service (RDS)

 

Correct Answer: C

 

 

QUESTION 130

DRAG DROP

You are developing a transactional application that debits customer accounts.

 

The application tracks account data in a local Microsoft SQL Server database and a web service.

 

You need to ensure that the transaction rolls back the operation in the local database and in the web service if an exception occurs.

 

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_image003

 

Correct Answer:

clip_image005

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…