繁体   English   中英

C#LINQ-to-SQL多重选择

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

我知道了,它在我的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));
    }

但是我遇到了2个问题,不是每个表都可能返回结果,并且如果提供的contentID不正确(不是有效的内容编号),则它会失败并生成以下错误:“为函数'GetContent'声明了多个结果类型,不返回IMultipleResults。”

任何想法如何解决这个问题?

您可以更改存储过程,以便在提供不正确的contentID时返回空表吗? (而不是返回消息或当前执行的任何操作)

如果不能保证您的存储过程每次都返回相同数量的表,那么您将需要花费大量时间来确定哪些表已返回...

暂无
暂无

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

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