mirror of
https://github.com/FalconWu2017/Falcon.StoredProcedureRunner.git
synced 2024-11-23 13:39:38 +08:00
修复一个存储过程参数获取错误的问题
This commit is contained in:
parent
ea03882717
commit
9b1b54c5ec
|
@ -21,7 +21,7 @@ namespace Falcon.StoredProcedureRunner
|
|||
/// <param name="db">数据上下文</param>
|
||||
/// <param name="data">参数数据</param>
|
||||
public int Execute<TPrarmType>(DbContext db,TPrarmType data) {
|
||||
var parms = getParams(data).ToArray();
|
||||
var parms = getParams(typeof(TPrarmType),data).ToArray();
|
||||
var pName = getProcuderName<TPrarmType>();
|
||||
|
||||
#if NETSTANDARD2_1
|
||||
|
@ -75,7 +75,7 @@ namespace Falcon.StoredProcedureRunner
|
|||
/// <returns>查询结果枚举</returns>
|
||||
public IEnumerable<object> Run(DbContext db,Type prarmType,Type returnType,object data) {
|
||||
var pm = getProcuderName(prarmType);
|
||||
var paras = getParams(data).ToArray();
|
||||
var paras = getParams(prarmType,data).ToArray();
|
||||
var connection = db.Database.GetDbConnection();
|
||||
using(var cmd = connection.CreateCommand()) {
|
||||
cmd.CommandText = pm;
|
||||
|
@ -134,12 +134,12 @@ namespace Falcon.StoredProcedureRunner
|
|||
/// <summary>
|
||||
/// 获取存储过程参数枚举
|
||||
/// </summary>
|
||||
/// <typeparam name="T">参数模型类型</typeparam>
|
||||
///<param name="type">数据的类型</param>
|
||||
/// <param name="data">参数实例</param>
|
||||
private static IEnumerable<SqlParameter> getParams<T>(T data) {
|
||||
private static IEnumerable<SqlParameter> getParams(Type type,object data) {
|
||||
if(data == null)
|
||||
yield break;
|
||||
foreach(var p in typeof(T).GetProperties()) {
|
||||
foreach(var p in type.GetProperties()) {
|
||||
if(!p.CanRead || ignoreProp(p))
|
||||
continue;
|
||||
var pt = getPrarmType(p);
|
||||
|
|
Loading…
Reference in New Issue
Block a user