Can SQL level functions be made available to LINQ to Entity queries?

前端 未结 2 1257
Happy的楠姐
Happy的楠姐 2021-01-23 03:07

I wish I could write LINQ to Entity queries that called other functions:

from c in context.Widgets
where MyFunc(c.name)
select c

That causes an

2条回答
  •  死守一世寂寞
    2021-01-23 04:08

    You should create a user-defined function MyFunc in the database and "import" it manually into your context (edmx, so database first), both in the XML and as a stub in a partial class off the context class. The procedure is described here:

    How to use a custom database function (Note that "StorageNamespace" is the namespace that you find in the XML file under .

    MSDN has a similar description.

提交回复
热议问题