Ok, so I'm not using Sql Client.
I have an .edmx file in my project and in it are the tables, the views and the stored procedures. I know how to call them from my project. But I have some functions in the Server Explorer. How to call them via code?
Ok, so I'm not using Sql Client.
I have an .edmx file in my project and in it are the tables, the views and the stored procedures. I know how to call them from my project. But I have some functions in the Server Explorer. How to call them via code?
You just need to add those function to EDMX in Wizard (update model from database) and after that you have to manually create static function accepting parameters with same names and marked with EdmFunction attribute (examples in this question). Now you have mapped function which can be used inside Linq-to-entities queries. EF provider will correctly translate your CLR call to SQL function call in SQL query.
EF 4.0 doesn't support table valued functions (this support is added in EF 4.5 / .NET 4.5). Also this mapping works only with EDMX - not with code first.