这是我的代码。对于FromSqlInterpolated
,它可以正常运行,但存储过程不能运行imo。对于ExecuteSqlCommand
,它运行时在@p0
上有语法错误
var a = "abc";
var b = 10;
var result = _dataContext.FileFolders.FromSqlInterpolated($"EXECUTE dbo.AddFileFolderStructure {10} {a} {a}");
// _dataContext.Database
.ExecuteSqlCommand("dbo.AddFileFolderStructure @p0 @p1 @p2", b, a, a);
_dataContext.SaveChanges();
我也在下面尝试过
var id = new SqlParameter("id", 10);
var folderName = new SqlParameter("folderName", "1");
var folderType = new SqlParameter("folderType", "5");
var result = _dataContext.FileFolders.FromSqlRaw($"EXECUTE dbo.AddFileFolderStructure {id} {folderName} {folderType}");
_dataContext.SaveChanges();