简体   繁体   English

C#LINQ-to-SQL多重选择

[英]C# LINQ-to-SQL Multiple selects

I got this, its calling a SP in my MS SQL 2008 database: 我知道了,它在我的MS SQL 2008数据库中调用了SP:

[Function(Name = "dbo.Content_GetContent")]
    [ResultType(typeof(Content_GetContentResult))]
    [ResultType(typeof(Content_GetContentImagesResult))]
    [ResultType(typeof(Content_GetContentBoxesResult))]
    [ResultType(typeof(Content_GetContentSearchWordsResult))]
    public IMultipleResults GetContent([Parameter(DbType = "INT")]int? contentID)
    {
        IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), contentID);
        return ((IMultipleResults)(result.ReturnValue));
    }

But i got 2 problems, not every table might return a result and if the contentID supplied is incorrect (not a valid content number) then it fails and it generates the following error: "More than one result type declared for function 'GetContent' that does not return IMultipleResults." 但是我遇到了2个问题,不是每个表都可能返回结果,并且如果提供的contentID不正确(不是有效的内容编号),则它会失败并生成以下错误:“为函数'GetContent'声明了多个结果类型,不返回IMultipleResults。”

Any ideas how to solve this? 任何想法如何解决这个问题?

Can you change the stored procedure so that it returns empty tables when an incorrect contentID is supplied? 您可以更改存储过程,以便在提供不正确的contentID时返回空表吗? (instead of returning a message or whatever it does at the moment) (而不是返回消息或当前执行的任何操作)

If your stored procedure is not guaranteed to return the same number of tables each time then you're in for a tricky time working out which ones did get returned ... 如果不能保证您的存储过程每次都返回相同数量的表,那么您将需要花费大量时间来确定哪些表已返回...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM