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 error because the expression obviously can’t be converted to TSQL that calls MyFunc.
Well, I’m thinking, unless MyFunc was either a user defined function or (I think better yet) a SQL/CLR function.
So is this possible, and moreover is it recommended?
If it’s not possible, is my desire to have this feature valid and possibly going to be addressed by a future of ADO.NET?
You should create a user-defined function
MyFuncin 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
<edmx:StorageModels><Schema Namespace=....MSDN has a similar description.