Wednesday, June 19, 2013

Entity Framework: Calling SQL Server specific functions

Calling a SQL Function from your Entity Framework LINQ query is easy thanks to the availability of the SqlFunctions class. This class provides methods that call functions in the database in LINQ to Entities queries.

Here is an example where I call the DatePart function:

Remark: The SqlFunctions specifically apply to SQL Server and cannot be used for other databases.

No comments: