nerdexam
Microsoft

70-516 · Question #169

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework. The application defines the following Entity Data Model. Within the…

The correct answer is B. public static class DecimalHelper. EdmFunctionAttribute Class us/library/system.data.objects.dataclasses.edmfunctionattribute.aspx) How to: Call Model-Defined Functions in Queries The model-defined function has been created in the conceptual model, but you still need a way to connect your code to it. To do so…

Querying Data

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework. The application defines the following Entity Data Model. Within the .edmx file, the following function is defined:

<Function Name=”Round” ReturnType=”Decimal”> <Parameter Name=”val” Type=”Decimal” /> <DefiningExpression> CAST(val as Edm.Int32) </DefiningExpression> </Function> The application includes the following LINQ query. var query = from detail in context.SalesOrderDetails select detail.LineTotal.Round(); You need to ensure that the Round function executes on the database server when the query is executed. Which code segment should you use?

Options

  • Apublic static class DecimalHelper
  • Bpublic static class DecimalHelper
  • Cpublic static class DecimalHelper
  • Dpublic static class DecimalHelper

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    73% (19)
  • C
    8% (2)
  • D
    15% (4)

Explanation

EdmFunctionAttribute Class us/library/system.data.objects.dataclasses.edmfunctionattribute.aspx) How to: Call Model-Defined Functions in Queries The model-defined function has been created in the conceptual model, but you still need a way to connect your code to it. To do so, add a function into your C# code, which will have to be annotated with the EdmFunctionAttribute attribute. This function can be another instance method of the class itself, but best practice is to create a separate class and define this method as static.

Topics

#Entity SQL#custom functions#DefiningExpression#LINQ to Entities

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice