在Linq中调用用户定义函数时出错 [英] Error to Calling User Defined Function in Linq

查看:90
本文介绍了在Linq中调用用户定义函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<跨度类= "x_x_short_text" ID = "x_x_result_box" LANG = "EN" 的tabindex = " - 1"> <跨度类= "x_x_hps"> I <跨度>已经创建 一个函数 名为 compcode
,但是当我从linq命令调用它时,我得到错误(
在图片 <跨度类= "x_x_hps">)

I've createda function calledcompcode , but when i calling it from linq Command , i get Error (below Picture)

帮助请<跨度类=" x_x_short_text "id ="x_x_result_box"lang ="en"tabindex =" - 1">

help please

 Dim cl As New Class1

        Dim db As New WebDatabaseEntities
        Dim query = From l In db.ListMonHed
                    Join k In db.KarSpec
                    On l.KarId Equals k.id
                    Where l.KarId = k.id And l.Userid = userid
                    Order By l.id Descending
                    Select New With {Key .id = l.id, .fullname = k.KarName + " - " + k.KarNo, .pymno = l.PymNo,
                                       .Dore = cl.compCode(l.Year.ToString, 4) + "-" + cl.compCode(l.Month.ToString, 2), .listno = l.ListNo}

        With GridView1
            .DataSource = query.ToList
            .DataBind()
        End With




推荐答案

问题是您正在尝试让SQL Server在您的PC上执行代码。  您希望在执行语句中使用类cl(class1)。  这不起作用。

The problem is that you are trying to get SQL Server to execute code on your PC.  There is a class cl (class1) which you want to use to in the executing statement.  This won't work.

您需要做的是执行语句,然后在第二个语句中按下返回的数据。

What you will need to do is execute the statement and then massage the returned data in a second statement.


这篇关于在Linq中调用用户定义函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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