This commit is contained in:
sunkaixuan
2017-05-28 18:43:27 +08:00
parent 40243b297e
commit d9d21222ba

View File

@@ -45,31 +45,20 @@ namespace SqlSugar
if (parameters != null) if (parameters != null)
{ {
var entityType = parameters.GetType(); var entityType = parameters.GetType();
var isDic = entityType.IsIn(PubConst.DicArraySO, PubConst.DicArraySS); var isDictionary = entityType.IsIn(PubConst.DicArraySO, PubConst.DicArraySS);
if (isDic) if (isDictionary)
{ {
if (entityType == PubConst.DicArraySO) DictionaryToParameters(parameters, sqlParameterKeyWord, listParams, entityType);
{
var newObj = (Dictionary<string, object>)parameters;
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParameterSize(par);
}
listParams.AddRange(pars);
} }
else else
{ {
var newObj = (Dictionary<string, string>)parameters; ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, listParams, entityType);
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParameterSize(par);
}
listParams.AddRange(pars); ;
} }
} }
else return listParams.ToArray();
}
protected void ProperyToParameter(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
{ {
PropertyInfo[] propertiesObj = null; PropertyInfo[] propertiesObj = null;
if (propertyInfo != null) if (propertyInfo != null)
@@ -108,8 +97,28 @@ namespace SqlSugar
} }
} }
} }
protected void DictionaryToParameters(object parameters, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
{
if (entityType == PubConst.DicArraySO)
{
var newObj = (Dictionary<string, object>)parameters;
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParameterSize(par);
}
listParams.AddRange(pars);
}
else
{
var newObj = (Dictionary<string, string>)parameters;
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParameterSize(par);
}
listParams.AddRange(pars); ;
} }
return listParams.ToArray();
} }
} }
} }