nam*_*nam 1 c# entity-framework-core asp.net-core
在以下代码的最后一行上获得上述错误.我正在使用EF Core 1.1
.试图遵循这个建议.
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient; //Visual Studio had greyed out this line suggesting this as unnecessary.
var conn = _context.Database.GetDbConnection();
var cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "MySproc";
cmd.Parameters.AddWithValue("@MyParameter", 42);
Run Code Online (Sandbox Code Playgroud)
这是使用System.Data.Common API的等效代码.(它可以与任何ADO.NET提供程序一起使用.)
var parameter = cmd.CreateParameter();
parameter.ParameterName = "@MyParameter";
parameter.Value = 42;
cmd.Parameters.Add(parameter);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1841 次 |
最近记录: |