LINQ 问题,拖动存储过程返回 int 而不是 Result
这是存储过程。
ALTER PROCEDURE [dbo].[UserSearch] ( ) AS SET NOCOUNT ON DECLARE @temp TABLE ( Id INT, UserName INT, StatusId INT ) INSERT INTO @temp SELECT userId, userName, statusId FROM [User] SELECT UserId, COUNT(ISNULL(StatusId, 0)) AS UserCount, StatusTypeName FROM @temp GROUP BY StatusTypeId, StatusTypeName
当我运行这个时,它工作正常。昨天,当我将此存储过程拖动到 dbml 文件的方法窗格中时,它不会创建 UserSearchResult 类,而是返回 int 而不是 ISingleResult。但今天早上我再次拖动它,现在它已经创建了类并且还返回 ISingleResult,这是正确的。但我对 linq 行为太困惑了,为什么会发生这种情况?太浪费我的时间了。
This is the stored procedure.
ALTER PROCEDURE [dbo].[UserSearch] ( ) AS SET NOCOUNT ON DECLARE @temp TABLE ( Id INT, UserName INT, StatusId INT ) INSERT INTO @temp SELECT userId, userName, statusId FROM [User] SELECT UserId, COUNT(ISNULL(StatusId, 0)) AS UserCount, StatusTypeName FROM @temp GROUP BY StatusTypeId, StatusTypeName
When i run this then it works fine. Yesterday when i drag this stored procedure in the method pane in dbml file then it doesn't create UserSearchResult class and it returns int rather than ISingleResult. But today in the morning i have dragged it again and now it has created the class and also returns ISingleResult, which is correct. But i am too much confuse with the linq behavior why this occur? It waste my time too much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当这种情况发生在我身上取决于连接对存储过程的访问级别。如果您没有执行访问权限,它将返回一个整数,因为存储过程始终返回一个整数。
它还可能与存储过程末尾没有 SELECT 语句有关,因为它使用这些语句来确定结果类型。
希望这有帮助
When that happens to me depends on the access level that the connection has on the Stored Procedure. If you don't have execution access it will return an integer because a Stored Procedure always return an integer.
Also it can be related to not having the SELECT statement(s) at the end of your stored procedure, because it uses those statements to figure out the result types.
Hope this helps