dbml生成ISingleResult< object>.我想要收集时从存储过程中获取 [英] dbml generates ISingleResult<object> from my stored procedure when I want a collection

查看:78
本文介绍了dbml生成ISingleResult< object>.我想要收集时从存储过程中获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个存储过程,并将其拖到dbml文件中,希望它创建一个将返回对象集合的方法.但是,它只给我一种返回ISingleResult的方法.

I've created a stored procedure which I've dragged on to my dbml file expecting it to create a method that will return a collection of objects. However it only gives me a method returning an ISingleResult.

我存储的proc创建一个表变量,用数据填充该变量,然后从该表中选择所有变量.

My stored proc creates a table variable, populates it with data and then selects all from that table.

知道我在做什么错吗?如果可以的话,我可以发布代码.

Any idea what I'm doing wrong? I can post code if that would be helpful.

编辑.这是从dbml生成的代码

Edit. Here's the generated code from the dbml

[Function(Name="dbo.gr_RecentActions")]
public ISingleResult<Action> gr_RecentActions([Parameter(Name="UserID", DbType="UniqueIdentifier")] System.Nullable<System.Guid> userID)
{
    IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), userID);
    return ((ISingleResult<Action>)(result.ReturnValue));
}

这是存储过程的一部分.简直就是这样.

Here's a section of the stored procedure. It's pretty much this straightforward.

    ALTER PROCEDURE [dbo].[gr_RecentActions]
@UserID UNIQUEIDENTIFIER
AS
BEGIN

DECLARE @RecentActions AS TABLE (UserId UNIQUEIDENTIFIER, UserID1 UNIQUEIDENTIFIER, Name VARCHAR(500), GiftID UNIQUEIDENTIFIER, ActionType VARCHAR(20), ActionDate DATETIME)

DECLARE @Friends AS Table (Userid UNIQUEIDENTIFIER)

INSERT INTO @Friends (Userid)
    (SUBQUERY...)



INSERT INTO @RecentActions (UserId, UserId1, Name, GiftID, ActionType, ActionDate)
    SELECT userid, NULL, Name, g.GiftId, 'GiftAdded', DateCreated FROM Gift g 
    WHERE UserId IN 
        (select UserId from @Friends)

/* SNIP.... SIMILAR CODE TO ABOVE */


SELECT * FROM @RecentActions ORDER BY ActionDate DESC

推荐答案

ISingleResult<T>继承IEnumerable<T>.它是一个集合.

ISingleResult<T> inherits IEnumerable<T>. It is a collection.

在多个结果集中,它是单个结果,而不是多个结果:

It's a single result as opposed to a multiple result, as in multiple result sets:

SELECT *
FROM Table1

SELECT *
FROM Table2

类似的存储过程不会返回ISingleResult<T>.

A stored procedure like that would not return ISingleResult<T>.

这篇关于dbml生成ISingleResult&lt; object&gt;.我想要收集时从存储过程中获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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