mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 03:53:21 +08:00
- 完善 InsertDict 等字典操作功能;
This commit is contained in:
parent
4cf47488d4
commit
5b65a17be0
@ -538,14 +538,5 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
|
||||||
<summary>
|
|
||||||
批量注入 Repository,可以参考代码自行调整
|
|
||||||
</summary>
|
|
||||||
<param name="services"></param>
|
|
||||||
<param name="globalDataFilter"></param>
|
|
||||||
<param name="assemblies"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
@ -36,6 +36,8 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
public void InsertDictionary()
|
public void InsertDictionary()
|
||||||
{
|
{
|
||||||
var fsql = g.sqlserver;
|
var fsql = g.sqlserver;
|
||||||
|
fsql.Delete<object>().AsTable("table1dict").Where("1=1").ExecuteAffrows();
|
||||||
|
|
||||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||||
dic.Add("id", 1);
|
dic.Add("id", 1);
|
||||||
dic.Add("name", "xxxx");
|
dic.Add("name", "xxxx");
|
||||||
@ -55,6 +57,27 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
Assert.Equal(@"INSERT INTO [table1]([id], [name]) VALUES(1, N'xxxx')", sql3);
|
Assert.Equal(@"INSERT INTO [table1]([id], [name]) VALUES(1, N'xxxx')", sql3);
|
||||||
var sql4 = fsql.InsertDict(diclist).AsTable("table1").NoneParameter().ToSql();
|
var sql4 = fsql.InsertDict(diclist).AsTable("table1").NoneParameter().ToSql();
|
||||||
Assert.Equal(@"INSERT INTO [table1]([id], [name]) VALUES(1, N'xxxx'), (2, N'yyyy')", sql4);
|
Assert.Equal(@"INSERT INTO [table1]([id], [name]) VALUES(1, N'xxxx'), (2, N'yyyy')", sql4);
|
||||||
|
|
||||||
|
Assert.Equal(1, fsql.InsertDict(dic).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
Assert.Equal(1, fsql.DeleteDict(dic).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
Assert.Equal(1, fsql.InsertDict(dic).AsTable("table1dict").NoneParameter().ExecuteAffrows());
|
||||||
|
Assert.Equal(1, fsql.DeleteDict(dic).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
|
||||||
|
Assert.Equal(2, fsql.InsertDict(diclist).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
Assert.Equal(2, fsql.DeleteDict(diclist).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
Assert.Equal(2, fsql.InsertDict(diclist).AsTable("table1dict").NoneParameter().ExecuteAffrows());
|
||||||
|
Assert.Equal(2, fsql.DeleteDict(diclist).AsTable("table1dict").ExecuteAffrows());
|
||||||
|
|
||||||
|
|
||||||
|
var dicRet = fsql.InsertDict(dic).AsTable("table1dict").ExecuteInserted();
|
||||||
|
dicRet = fsql.DeleteDict(dic).AsTable("table1dict").ExecuteDeleted();
|
||||||
|
dicRet = fsql.InsertDict(dic).AsTable("table1dict").NoneParameter().ExecuteInserted();
|
||||||
|
dicRet = fsql.DeleteDict(dic).AsTable("table1dict").ExecuteDeleted();
|
||||||
|
|
||||||
|
dicRet = fsql.InsertDict(diclist).AsTable("table1dict").ExecuteInserted();
|
||||||
|
dicRet = fsql.DeleteDict(diclist).AsTable("table1dict").ExecuteDeleted();
|
||||||
|
dicRet = fsql.InsertDict(diclist).AsTable("table1dict").NoneParameter().ExecuteInserted();
|
||||||
|
dicRet = fsql.DeleteDict(diclist).AsTable("table1dict").ExecuteDeleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -772,7 +772,7 @@ SELECT ");
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int ExecuteAffrows() => _insertProvider.ExecuteAffrows();
|
public int ExecuteAffrows() => _insertProvider.ExecuteAffrows();
|
||||||
public long ExecuteIdentity() => _insertProvider.ExecuteAffrows();
|
public long ExecuteIdentity() => _insertProvider.ExecuteIdentity();
|
||||||
public List<Dictionary<string, object>> ExecuteInserted() => _insertProvider.ExecuteInserted();
|
public List<Dictionary<string, object>> ExecuteInserted() => _insertProvider.ExecuteInserted();
|
||||||
|
|
||||||
#if net40
|
#if net40
|
||||||
|
@ -1507,7 +1507,7 @@ namespace FreeSql.Internal
|
|||||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == typeof(object) && indexes != null)
|
if (type == typeof(object) && indexes != null || type == typeof(Dictionary<string, object>))
|
||||||
{
|
{
|
||||||
Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo> dynamicFunc = (type2, indexes2, row2, dataindex2, commonUtils2) =>
|
Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo> dynamicFunc = (type2, indexes2, row2, dataindex2, commonUtils2) =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user