小编Muh*_*tab的帖子

System.InvalidCastException: 'SqlParameterCollection 只接受非空的 SqlParameter 类型对象,不接受 SqlParameter 对象。

我将我的项目从 ASP.NET Core 2.2 迁移到 ASP.NET Core 3.0。现在我得到了这个例外。在 ASP.NET Core 2.2 中,它使用FromSql(); 现在它正在使用FromSqlRaw(). 我正在使用 Entity Framework Core 调用我的过程。

SqlParameter Username = new SqlParameter
            {
                ParameterName = "USERNAME",
                SqlDbType = SqlDbType.NVarChar,
                Value = user.Username,
                Direction = ParameterDirection.Input,
                Size = 50
            };

SqlParameter Password = new SqlParameter
            {
                ParameterName = "PASSWORD",
                SqlDbType = SqlDbType.NVarChar,
                Value = user.Password,
                Direction = ParameterDirection.Input,
                Size = 50
            };

SqlParameter msgOut = new SqlParameter
            {
                ParameterName = "MSG",
                SqlDbType = SqlDbType.NVarChar,
                Direction = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net sqlclient asp.net-core asp.net-core-3.0

9
推荐指数
2
解决办法
4761
查看次数

标签 统计

asp.net ×1

asp.net-core ×1

asp.net-core-3.0 ×1

c# ×1

sqlclient ×1