C# EF核心存储过程:获取';找不到隐式类型数组的最佳类型';过帐多个参数时出错

C# EF核心存储过程:获取';找不到隐式类型数组的最佳类型';过帐多个参数时出错,c#,stored-procedures,entity-framework-core,C#,Stored Procedures,Entity Framework Core,我尝试使用EF核心的存储过程。我的目的是从数据库表中获取行数,但我不能发送多个参数。我得到一个错误: 找不到隐式类型数组的最佳类型 实际上我不知道如何使用Linq语法。提前谢谢 存储过程: create proc sp_getExistorNExistCountStd @Date datetime2(7), @ClassId int, @Absent bit, @Count int out as begin select @Count = COUNT(*

我尝试使用EF核心的存储过程。我的目的是从数据库表中获取行数,但我不能发送多个参数。我得到一个错误:

找不到隐式类型数组的最佳类型

实际上我不知道如何使用Linq语法。提前谢谢

存储过程:

create proc sp_getExistorNExistCountStd 
    @Date datetime2(7),
    @ClassId int,
    @Absent bit,
    @Count int out
as
begin
    select @Count = COUNT(*) 
    from RollCalls
    where DateRollCall = @Date 
      and ClassId = @ClassId 
      and [Absent] = @Absent

    return @Count
end
#


我没有找到使用输出参数计算行数的解决方案,但找到了另一个解决方案。。这种方法给了我想要的

Create proc [dbo].[sp_getExistorNExistCountStd] 
    @Date datetime2(7),
    @ClassId int,
    @Absent bit     
    as
    begin

        select Id from RollCalls
        where DateRollCall=@Date 
        and ClassId=@ClassId 
        and [Absent]=@Absent
    end


为什么使用存储过程?

EF生成的sql非常智能。您是否尝试过:
db.RollCalls.Where(rc=>DateTime.Now.Date.Equals(rc.DateRollCall)/*&&other conditions*/).Count()

改用
新对象[]{…}
。旁注:存储过程不应使用
sp.
前缀。微软已经这样做了,而且你确实有可能在将来的某个时候发生名称冲突。最好只是简单地避免使用
sp.
并使用其他东西作为前缀,或者根本不使用前缀!是的,我知道通过thids方法获取count,但我想使用存储过程(尤其是不带out参数的存储过程)来查看这两种方法在性能方面的差异。
Create proc [dbo].[sp_getExistorNExistCountStd] 
    @Date datetime2(7),
    @ClassId int,
    @Absent bit     
    as
    begin

        select Id from RollCalls
        where DateRollCall=@Date 
        and ClassId=@ClassId 
        and [Absent]=@Absent
    end
 int ExistStdCount = db.RollCalls.FromSql("sp_getExistorNExistCountStd @p0 ,@p1, @p2",
             DateTime.Now.Date.ToString("yyyyMMdd"), classIds[i], 0).ToList().Count();