mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 完善 所有参数化 object parms 可使用 IDictionary 类型传入;
This commit is contained in:
parent
dda7c8bc9c
commit
b5efb387bd
@ -99,6 +99,13 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
||||||
|
<summary>
|
||||||
|
根据 lambda 条件删除数据
|
||||||
|
</summary>
|
||||||
|
<param name="predicate"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
|
@ -167,6 +167,12 @@ namespace FreeSql.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Test02()
|
public void Test02()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var dicParamslist = g.sqlite.Select<SysModule>().Page(1, 10)
|
||||||
|
.Where("id > @id and id > @id2 and id > @id3",
|
||||||
|
new Dictionary<string, int> { ["id"] = 1, ["id2"] = 2, ["id3"] = 3 })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var list111 = g.sqlite.Select<SysModule>()
|
var list111 = g.sqlite.Select<SysModule>()
|
||||||
.Page(1, 10)
|
.Page(1, 10)
|
||||||
.ToList(a => new { Id = a.Id })
|
.ToList(a => new { Id = a.Id })
|
||||||
|
@ -1024,6 +1024,20 @@ namespace FreeSql.Internal
|
|||||||
var type = obj.GetType();
|
var type = obj.GetType();
|
||||||
if (type == ttype) return new[] { (T)Convert.ChangeType(obj, type) };
|
if (type == ttype) return new[] { (T)Convert.ChangeType(obj, type) };
|
||||||
var ret = new List<T>();
|
var ret = new List<T>();
|
||||||
|
var dic = obj as IDictionary;
|
||||||
|
if (dic != null)
|
||||||
|
{
|
||||||
|
foreach (var key in dic.Keys)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(paramPrefix) == false && sql.IndexOf($"{paramPrefix}{key}", StringComparison.CurrentCultureIgnoreCase) == -1) continue;
|
||||||
|
var val = dic[key];
|
||||||
|
var valType = val == null ? typeof(string) : val.GetType();
|
||||||
|
if (valType == ttype) ret.Add((T)Convert.ChangeType(val, ttype));
|
||||||
|
else ret.Add(constructorParamter(key.ToString(), valType, val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var ps = type.GetPropertiesDictIgnoreCase().Values;
|
var ps = type.GetPropertiesDictIgnoreCase().Values;
|
||||||
foreach (var p in ps)
|
foreach (var p in ps)
|
||||||
{
|
{
|
||||||
@ -1032,6 +1046,7 @@ namespace FreeSql.Internal
|
|||||||
if (p.PropertyType == ttype) ret.Add((T)Convert.ChangeType(pvalue, ttype));
|
if (p.PropertyType == ttype) ret.Add((T)Convert.ChangeType(pvalue, ttype));
|
||||||
else ret.Add(constructorParamter(p.Name, p.PropertyType, pvalue));
|
else ret.Add(constructorParamter(p.Name, p.PropertyType, pvalue));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret.ToArray();
|
return ret.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user