微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linq-to-sql – 如何在linq中调用UDF到sql查询?

如何将以下sql语句转换为 linq查询
select ID,Price,dbo.fgetText(DescriptionID,defaultLanguage,currentUserLanguage) 
from Products

UDF fgetText非常实用,并且在整个代码库中使用,因此需要进行封装(作为UDF或其他方式,可能是Linq Expression).

不能选择往返数据库服务器.应该只有一个查询,检索3个字段.

非常感谢您的帮助.非常感谢.

解决方法

这是MSDN文章

How to: Call User-Defined Functions Inline (LINQ to SQL)

来自同一页面的说明:

Although you can call user-defined
functions inline,functions that are
included in a query whose execution is
deferred are not executed until the
query is executed. For more
information,see Introduction to LINQ
Queries.

When you call the same function
outside a query,LINQ to sql creates a
simple query from the method call
expression

另外,看看这个13 min screencast.

原文地址:https://www.jb51.cc/mssql/76983.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐