加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 07:06:37 所属栏目:MsSql教程 来源:网络整理
导读:如何将以下sql语句转换为 linq查询? select ID,Price,dbo.fGetText(DescriptionID,defaultLanguage,currentUserLanguage) from Products UDF fGetText非常实用,并且在整个代码库中使用,因此需要进行封装(作为UDF或其他方式,可能是Linq Expression). 不能选择
如何将以下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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读