0

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?

4

2 回答 2

1

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 不支持表值函数(在 EF 4.5 / .NET 4.5 中添加了此支持)。此外,此映射仅适用于 EDMX - 不适用于代码。

于 2012-06-13T12:00:44.190 回答
0

我所做的是使用与存储过程相同的代码编写一个存储过程,并将其导入到 .edmx 文件中。

于 2012-06-15T08:48:35.690 回答