只有在调用存储过程时Type.IsGenericParameter为true的Type上才能调用方法

时间:2013-10-28 09:51:33

标签: c# entity-framework stored-procedures

在我的解决方案中,我有一个静态方法,它调用将返回消息的存储过程。当我调用此程序时,我得到上述错误。

我正在使用实体框架

System.Data.Objects.ObjectParameter returnMessage = new System.Data.Objects.ObjectParameter("ReturnMessage", typeof(string));

//TO VALIDATE IF DISCOUNT HAS ALREADY BEEN APPLIED TO AN INVOICE
dbTCMS.SP_CheckForInvoice(int.Parse(discount.EntityNo), DateTime.Now, discount.ProductDescription, returnMessage);

if (!string.IsNullOrEmpty(returnMessage.Value.ToString()))
    return returnMessage.Value.ToString();

objectParamer returnMessage返回null值。

我不知道如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法。我存储过程返回一个列表,然后调用SP应该是这样的:

var s = dbTCMS.SP_CheckForInvoice(int.Parse(discount.EntityNo), DateTime.Now, discount.ProductDescription, returnMessage);

然后你可以枚举结果集。

如果SP只返回一个值,那么就像这样调用它:

dbTCMS.SP_CheckForInvoice(int.Parse(discount.EntityNo), DateTime.Now, discount.ProductDescription, returnMessage);

我不得不改变我的程序,它不返回结果集