加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 数据库 > MsSql > 正文

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

发布时间:2020-05-24 08:15:53 所属栏目:MsSql 来源:互联网
导读:如何将以下sql语句转换为 linq查询? select ID, Price, dbo.fGetText(DescriptionID, defaultLanguage, currentUserLanguage) from Products UDF fGetText非常实用,并且在整个代码库中使用,因此需要进行封装(作为UDF或其他方式,可能是Linq Expres

如何将以下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.

(编辑:安卓应用网)

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

    推荐文章
      热点阅读