PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

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 6ID = SCOPE_IDENTITY()
You need to insert a new department and display the generated ID.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Using context As New SchoolEntities()
Dim id As ObjectParameter = Nothing context.InsectDepartment(“Department 1”, id)
Console.WriteLine(id.Value) End Using

B.
Using context As New SchoolEntities()
Dim id = New ObjectParameter(“ID”, GetType(Integer)) context.InsertDepartment(“Department 1”,
id) Console.WriteLine(id.Value) End Using

C.
Using context As New SchoolEntities()
Dim id = New ObjectParameter(“ID”, Nothing) context.InsertDepartment(“Department 1”, id)
Console.WriteLine(id.Value) End Using

D.
Using contexc As New SchoolEntities()
Dim id = context.InsertDepartment(“Department 1”, Nothing)
Console.WriteLine(id)
End Using

Explanation:
http://blogs.microsoft.co.il/blogs/gilf/archive/2010/05/09/how-to-retrieve-stored-procedureoutput-parameters-inentity-framework.aspx


Leave a Reply