You need to add a function that returns the number of years since a person was hired

You use Microsoft visual studio 2010 and Microsoft NET Framework 4 to create an Application. The
application uses the ADO NFT Entity Framework to model entities. The model includes the entity
shown in the following exhibit.

You need to add a function that returns the number of years since a person was hired. You also need
to ensure that the function can be used within LINQ to Entities queries. What should you do?

You use Microsoft visual studio 2010 and Microsoft NET Framework 4 to create an Application. The
application uses the ADO NFT Entity Framework to model entities. The model includes the entity
shown in the following exhibit.

You need to add a function that returns the number of years since a person was hired. You also need
to ensure that the function can be used within LINQ to Entities queries. What should you do?

A.
//Add the following conceptual model function returns the number of years since an instructor
was hired
<Function Name=”YearsSince” ReturnType=”Edm.Int32″>
<Parameter Name=”date” Type=”Edm.DateTime” />
<DefiningExpression>
Year(CurrentDateTime()) – Year(date)
</DefiningExpression>
</Function>

// add the following method to your application and use an EdmFunctionAttribute to map it to the
conceptual model function:
[EdmFunction(“SchoolModel”, “YearsSince”)]
public static int YearsSince(DateTime date)
{
throw new NotSupportedException(“Direct calls are not supported.”);
}

B.
//Add the following conceptual model function returns the number of years since an instructor
was hired
<Function Name=”YearsSince” ReturnType=”Edm.Int32″>
<Parameter Name=”date” Type=”Edm.DateTime” />
<DefiningExpression>
Year(CurrentDateTime()) – Year(date)
</DefiningExpression>
</Function>
// add the following method to your application and use an EdmFunctionAttribute to map it to the
conceptual model function:
[EdmFunction(“SchoolModel”, “YearsSince”)]
public static int YearsSince(DateTime date)
{
return CurrentDateTime() – Year(date);
}

C.
//Add the following conceptual model function returns the number of years since an instructor
was hired
<Function Name=”YearsSince” ReturnType=”Edm.Int32″>
<Parameter Name=”date” Type=”Edm.DateTime” />
<DefiningExpression>
YearsSince(DateTime date)
</DefiningExpression>
</Function>
// add the following method to your application and use an EdmFunctionAttribute to map it to the
conceptual model function:
[EdmFunction(“SchoolModel”, “YearsSince”)]
public static int YearsSince(DateTime date)
{
return CurrentDateTime() – Year(date);
}

D.
Use the Entity Data Model Designer to create a complex property named
YearsSinceNow that can be accessed throuqh the LINQ to Entites query at a Later time

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



Leave a Reply 0

Your email address will not be published. Required fields are marked *