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)
{
var entityType = parameters.GetType();
var isDic = entityType.IsIn(PubConst.DicArraySO, PubConst.DicArraySS);
if (isDic)
var isDictionary = entityType.IsIn(PubConst.DicArraySO, PubConst.DicArraySS);
if (isDictionary)
{
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);
DictionaryToParameters(parameters, sqlParameterKeyWord, listParams, entityType);
}
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); ;
ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, listParams, entityType);
}
}
else
return listParams.ToArray();
}
protected void ProperyToParameter(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
{
PropertyInfo[] propertiesObj = 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();
}
}
}