在LINQ查询中使用内置的sql函数? [英] Using built-in sql functions in a LINQ query?

查看:377
本文介绍了在LINQ查询中使用内置的sql函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能()在LINQ查询中使用buillt,像USER_NAME SQL函数?如果没有,我可以用别的东西吗?

Is it possible to use buillt-in sql functions like user_name() in a LINQ query? If not, can I use something else?

推荐答案

这取决于供应商。例如,在LINQ到对SQL Server实体可以使用的 SqlFunctions - 其中有一个的 用户名 对应的 USER_NAME() 在Transact-SQL。 (还有许多其他的方法和属性。对于当前用户,你可以使用的 的currentUser 属性,例如。)

It depends on the provider. For example, in LINQ to Entities against SQL Server you can use SqlFunctions - which has a UserName method which corresponds to USER_NAME() in Transact-SQL. (There are many other methods and properties. For the current user, you can just use the CurrentUser property, for example.)

这篇关于在LINQ查询中使用内置的sql函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆