使用 BLToolkit 和 Linq 的标量函数
我正在使用 BLToolkit 库将 SQL 过程转换为 Linq。
现在我遇到了一个小问题,所以如果有人知道这可能的话,我将非常感谢您的帮助。
不管怎样,我有一个看起来像这样的sql查询(注意:这不是我实际的表名,我只是翻译了它们,这样你们就可以理解发生了什么)
select
P.ProductsID,
P.Name,
P.Description,
dbo.GetTax(P.TaxID, getdate()) -- this is what I need help with
from
Products P
这里没有什么太奇特的,除了我需要为每个产品征税当天。
现在我需要将其转换为 Linq,但我不知道这是否可能。我尝试过类似的方法
from p in Products
select new
{
p.ProductsID,
p.Name,
p.Description,
GetTax(p.TaxID, DateTime.Today) //this is what I need help with
}
,但它不起作用。 GetWork 函数本质上只是另一个返回税金的 linq 查询。我不知道如何使用 BLToolkit 库调用标量函数。
所以问题是这样的。是否可以从 Linq selected 语句调用标量函数?
I'm in the process of converting my SQL procedures to Linq using the BLToolkit library.
Now I'm stuck on a little problem so if anyone know is this possible I will really appreciate the help.
Anyway I have the sql query that looks something like this (NOTE: this is not my actual table names, i just translated them so you guys can understand what's going on)
select
P.ProductsID,
P.Name,
P.Description,
dbo.GetTax(P.TaxID, getdate()) -- this is what I need help with
from
Products P
Nothing too fancy here except that I need to get the tax for every product on current day.
Now I need to convert this to Linq, but I don't know is this even possible. I tried something like this
from p in Products
select new
{
p.ProductsID,
p.Name,
p.Description,
GetTax(p.TaxID, DateTime.Today) //this is what I need help with
}
and it doesn't work. GetWork function is essentialy just another linq query that returns the tax. I don't know how to call the scallar function using BLToolkit library.
So the question is this. Is it possible to call scalar functions from Linq selected statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在某处定义以下函数。
它将告诉 BLToolkit 将 GetTax 转换为 SQL。
Define the following function somewhere.
It will tell BLToolkit to translate GetTax to SQL.