【发布时间】:2020-03-29 11:34:54
【问题描述】:
我有一个通过 LINQ 和 EF 调用的存储过程,它返回一个计数,并且该存储过程已经过试验和测试。
需要10个参数。
这些是存储过程采用的参数:
@StartDate DATETIME,
@EndDate DATETIME,
@Wards CodeTable READONLY,
@Clinicians CodeTable READONLY,
@Sites CodeTable READONLY,
@Specialities CodeTable READONLY,
@excludeCurrentInpatients BIT,
@DemoMode BIT,
@SortOrder Int,
@IsCurrent bit
这就是我在 LINQ 中的称呼方式:
public int Inpatient_Count(DateTime? startDate, DateTime? endDate, List<string> wards, List<string> clinicians, List<string> sites, List<string> specialities, bool excludeCurrentInpatients, bool demoMode, int sortOrder, bool IsCurrent)
{
using (DBName context = new DBName())
{
int total = context.SPROC_Name(startDate, endDate, wards, clinicians, sites, specialities, excludeCurrentInpatients, demoMode, sortOrder, IsCurrent);
return total;
}
}
我不断收到错误:
“SPROCName”的任何重载方法都需要 10 个参数
但我传递了十个参数。任何帮助将不胜感激。
【问题讨论】:
-
该过程在数据库中有 10 个参数并不意味着您的代码模型也正确反映了这一点。尝试刷新您的模型。如果这不起作用,请仔细检查您的代码和您正在查看的数据库是否相同。
-
这不是
LINQ,只是正常使用EF。另外,我不确定您是否可以直接传入列表。见here。 -
谢谢大家,我刷新了模型,现在它给了我另一个警告,说实体框架不支持(表类型)。
-
你在 Core 吗?还是框架?
-
我在框架中
标签: c# sql entity-framework linq tsql