Linq to SQL Designer和存储过程的问题 [英] Problem with Linq to SQL Designer and Stored Procs
问题描述
我遇到的问题似乎没有明确的分辨率。
有时当我从服务器资源管理器中将单个StoredProc拖到设计器中时,它不会创建正确的对象,这里是2个样本:
1)
< FunctionAttribute(Name:= " dbo.report_MonthlyRevenue" 跨度>)GT; _
<FunctionAttribute(Name:="dbo.report_MonthlyRevenue")> _
< span style ="color:blue">公共 功能 report_MonthlyRevenue()作为 ISingleResult(< span style ="color:blue"> report_MonthlyRevenueResult)
Public Function report_MonthlyRevenue() As ISingleResult(Of report_MonthlyRevenueResult)
Dim 结果 As IExecuteResult = Me .ExecuteMethodCall( Me , CType (MethodInfo.GetCurrentMethod) ,MethodInfo))
Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo))
返回 CType (result.ReturnV alue,ISingleResult( of report_MonthlyRevenueResult))
Return CType(result.ReturnValue,ISingleResult(Of report_MonthlyRevenueResult))
< span style ="font-size:9pt; font-family:'Courier New'"> 结束 功能
End Function
2)
< FunctionAttribute(Name:= " dbo.report_Payments_ByDate" )> _
<FunctionAttribute(Name:="dbo.report_Payments_ByDate")> _
< span style ="color:blue">公共 功能 report_Payments_ByDate(<参数(名称:= " ; ForDate" ,DbType:= " DateTime" )> ByVal forDate < span style ="color:blue"> As System.Nullable( of Date ), <参数(名称:= " BillingGroupUID" ,DbType:= " Int" ) > ByVal billingGroupUID 作为 System.Nullable(的 整数)) As 整数
Public Function report_Payments_ByDate(<Parameter(Name:="ForDate", DbType:="DateTime")> ByVal forDate As System.Nullable(Of Date), <Parameter(Name:="BillingGroupUID", DbType:="Int")> ByVal billingGroupUID As System.Nullable(Of Integer)) As Integer
Dim 结果 As IExecuteResult = Me .ExecuteMethodCall( Me , CType (MethodInfo.GetCurrentMethod,MethodInfo),forDate,billingGroupUID)
Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), forDate, billingGroupUID)
返回 CType (result.ReturnValue,整数)
Return CType(result.ReturnValue,Integer)
< span style ="font-size:9pt; font-family:'Courier New'"> 结束 功能
End Function
样本1正确,对象模型正确创建。样本2是错误的,它拒绝创建对象模型,而是将返回值设置为整数。
< font face = Calibri size = 3>
我没有设置@return在存储过程中,它也没有任何东西可以让我相信它会在返回值中返回一个Integer。我甚至试图关闭RowCount,看看是不是问题。 StoredProc中还有其他可能导致此行为的内容吗?它们都相当复杂并且功能几乎相同,除了#2使用临时表。 Temp表是这样做的吗?我没有在Docs警告中看到有关Temp Table或Table Variables的使用的任何内容。
BOTH StoredProcs返回普通旧选择[字段]从[表],所以我不知道如何让设计师正确看到这些。
< font face = Calibri size = 3>我当然可以手工编写report_Payments_ByDateResult并且它完全正常工作(没有得到一个整数,但表格。)
感谢任何帮助或链接。
Steele Price
Microsoft M. VP - Visual Basic
http://steeleprice.net
steeleprice@usa.net
推荐答案
有趣的是我刚遇到同样的问题,一个相当复杂的存储过程,当我添加临时表T-SQL的东西时,它只是强制设计者只返回一个int。
Interesting I have just come across this same problem, a fairly complex stored procedure that when I add in temporary table T-SQL stuff, it just forces the designer to only return an int.
如果你找到它的修复程序,我当然会有兴趣看到它,但此刻我正试图找到一个解决它的方法,或者更快地解决它......它总是有一些缺点。
If you find a fix for it, I would be interested to see it of course, but at the moment I am trying to find a work around for it or a quick fix even better.... there always has to be some drawback to it.
这篇关于Linq to SQL Designer和存储过程的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!