开发者

Stored Functions with Linq to Entities

开发者 https://www.devze.com 2023-01-01 21:37 出处:网络
How can I make a MS-SQL stored function availabe in LINQ expressions if using the Entity framework? The SQL function was crea开发者_运维问答ted with CREATE FUNCTION MyFunction(@name) ...). I was hopi

How can I make a MS-SQL stored function availabe in LINQ expressions if using the Entity framework?

The SQL function was crea开发者_运维问答ted with CREATE FUNCTION MyFunction(@name) ...). I was hoping to access it similarly to this:

var data = from c in entities.Users where MyFunction(c.name) = 3;

Unfortunately I have only .NET 3.5 available.


You actually can import DB functions in EF 1. But you don't get EdmFunctionAttribute in EF 1, so you're limited to the contexts where you can use them. You need EF 4 for that.

For your case you might want to consider mapping a proc returning Users (for 3.5; again, 4 is better for this feature).

0

精彩评论

暂无评论...
验证码 换一张
取 消