PrepAway - Latest Free Exam Questions & Answers

Category: 70-516 (v.2)

Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4 (update October 26th, 2015)

You need to provide a method named FormattedName() to format part names and color names throughout the applica

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

The application user interface displays part names or color names in many places as ‘## Name ##’.
You need to provide a method named FormattedName() to format part names and color names
throughout the application. What should you do?

Which code segment should you use?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

A performance issue exists in the application. The following code segment is causing a performance
bottleneck:
Dim colors = context.Parts.GetColors()

You need to improve application performance by reducing the number of database calls.
Which code segment should you use?

You need to resolve the exception without negatively impacting the rest of the application

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

You have a ContosoEntities context object named context and a Color object stored in a variable
named color.
You write the following code:
context.Colors.DeleteObject(color)
context.SaveChanges()
When the code runs, it generates the following exception:
System.Data.UpdateException:
An error occurred while updating the entries. See the inner exception for details. —>
System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE
constraint “FK_PartColor”. The conflict occurred in database “Contoso”, table “dbo.Parts”, column
‘ColorId’.
You need to resolve the exception without negatively impacting the rest of the application.
What should you do?

Which query parts should you use in sequence to complete the expression?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

DRAG DROP
The user interface requires that a paged view be displayed of all the products sorted in alphabetical
order. The user interface supplies a current starting index and a page size in variables named
startlndex and pageSize of type Integer. You need to construct a LINQ expression that will return the
appropriate Parts from the database from an existing ContosoEntities context object named context.
You begin by writing the following expression:

context.Paces
Which query parts should you use in sequence to complete the expression? (To answer, move the
appropriate actions from the list of actions to the answer area and arrange them in the correct
order.)

Which connection string fragment should you use?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

The 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?

You need to ensure that an exception is thrown when color names are set to less than two characters

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

You need to ensure that an exception is thrown when color names are set to less than two
characters. What should you do?

You need to add the following code to the \Model\Model.edmx file:

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

The Entity Data Model file (.edmx file) must be updated to support inheritance mapping for Products
and Components. You need to add the following code to the \Model\Model.edmx file:
• The code in line EX243 that maps the Product type
• the code in line EX250 that maps the Component type

What should you do?

Which code segment should you use?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

You are developing a new feature that displays an auto-complete list to users as they type color
names. You have an existing ContosoEntities context object named context. To support the new
feature you must develop code that will accept a string object named text containing a users partial
input and will query the Colors database table to retrieve all color names that begin with that input.
You need to create an Entity SQL (ESQL) query to meet the requirement. The query must not be
vulnerable to a SQL injection attack. Which code segment should you use?

Which expression should you use?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

The application must provide a component part list for any product. The component part list must
give the quantity of each distinct part that is required to manufacture that product. You need to
create a LINQ expression that delivers a result of type IEnumerable(Of Tuple(Of Integer, Part))to
meet the requirements. Which expression should you use?

Which of the following queries should you use?

###BeginCaseStudy###
Case Study: 1
Background
You are updating an existing Microsoft .NET Framework 4 application that includes a data
layer built with ADO.NET Entity Framework 4. The application communicates with a

Microsoft SQL Server 2008 instance named INST01 on a server named SQL01. The
application stores data in a database named Contoso in the INST01 instance.
You need to update the existing technology and develop new functionality by using
Microsoft Visual Studio 2010.
Application and Database Storage
The application tracks bicycle parts as they pass through a factory. Parts are represented by
the abstract Part entity and its associated partial classes. Each part has a name stored in the
Name field and a unique identifier stored in the Id field.
Parts are either component s (represented by the Component class) such as chains, wheels,
and frames, or finished product s (represented by the Product class) such as completed
bicycles. The Component class and the Product class derive from the Part class and may
contain additional class-specific properties.
Parts may have a color (represented by the Color class), but not all parts have a color, Parts
may be composed of other parts, and those parts may in turn be composed of other parts ; any
p art represents a tree of the parts that are used to build it, The lowest level of the tree consists
of c omponents that do not contain other component s.
A p roduct is a p art that has been completed and is ready to leave the factory. A p roduct
typically consists of many c omponents (forming a tree of child p arts) but can also be
constructed by combining other p roducts and/or c omponents to form a bundled p roduct,
such as a bicycle and a helmet that are sold together.
C omponents and p roducts are stored in a database table named Parts by using a table-perhierarchy (TPH) mapping. Components have a null ProductType field and a non-null
PartType field. Products have a non-null ProductType field and a null PartType field.
The following diagram illustrates the complete Entity data model diagram (EDMX diagram),

The following graphic illustrates detail s of the Part-Color Association.

The following code segments show relevant portions of the files referenced by the case study
items. (Line numbers in the samples below are included for reference only and include a twocharacter prefix that denotes the specific file to which they belong.)
Extension Methods.vb

Model.edmx

Model/Color.vb

Model/Component.vb

ModelContosoEntities.vb

Model IName.vb

Model Part.vb

Model Product.vb

sp_FindObsolete

###EndCaseStudy###

You need to write a LINQ query that can be used against a ContosoEntities context object named
context to find all parts that have a duplicate name. Which of the following queries should you use?
(Each correct answer presents a complete solution. Choose two.)


Page 31 of 31« First...1020...2728293031