entity framework7 FromSql存储过程返回值

我试图使用Entity Framework 7中的新FromSql命令返回一个值。如果一切顺利,我的存储过程返回值0,如果发生错误,则返回1。

我们可以使用FromSqlDbSet来做

 _dbContext.ExampleEntity.FromSql('someSproc', 'param') 

你将如何得到标量返回值0或1?

看起来存储过程支持仍在积压中 。

这是一个可以使用_dbContext.ExecuteStoredProcedure("someSproc", "param");调用的示例扩展方法_dbContext.ExecuteStoredProcedure("someSproc", "param");

 public static class DbContextExtension { public static int ExecuteStoredProcedure(this DbContext context, string name, string parameter) { var command = context.Database.GetDbConnection().CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = name; var param = command.CreateParameter(); param.ParameterName = "@p0"; param.Value = parameter; command.Parameters.Add(param); return (int)command.ExecuteScalar(); } }