mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
Json扩展支持JsonSerializerSettings
This commit is contained in:
@ -18,6 +18,8 @@ namespace base_entity
|
||||
{
|
||||
public int clicks { get; set; }
|
||||
public string title { get; set; }
|
||||
|
||||
public string nullvalue { get; set; }
|
||||
}
|
||||
[Table(Name = "sysconfig")]
|
||||
public class S_SysConfig<T> : BaseEntity<S_SysConfig<T>>
|
||||
@ -43,7 +45,7 @@ namespace base_entity
|
||||
.UseNoneCommandParameter(true)
|
||||
.UseConnectionString(FreeSql.DataType.Sqlite, "data source=test.db;max pool size=5")
|
||||
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=2")
|
||||
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3")
|
||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3")
|
||||
.UseLazyLoading(true)
|
||||
.Build();
|
||||
BaseEntity.Initialization(fsql);
|
||||
@ -59,10 +61,12 @@ namespace base_entity
|
||||
|
||||
var items1 = Products.Select.Limit(10).OrderByDescending(a => a.CreateTime).ToList();
|
||||
var items2 = fsql.Select<Products>().Limit(10).OrderByDescending(a => a.CreateTime).ToList();
|
||||
|
||||
BaseEntity.Orm.UseJsonMap();
|
||||
|
||||
new S_SysConfig<TestConfig> { Name = "testkey11", Config = new TestConfig { clicks = 11, title = "testtitle11" } }.Save();
|
||||
#if NETCORE30
|
||||
BaseEntity.Orm.UseJsonMap(new System.Text.Json.JsonSerializerOptions { IgnoreNullValues = true });
|
||||
#else
|
||||
BaseEntity.Orm.UseJsonMap(new JsonSerializerSettings { NullValueHandling=NullValueHandling.Ignore });
|
||||
#endif
|
||||
new S_SysConfig<TestConfig> { Name = "testkey11", Config = new TestConfig { clicks = 11, title = "testtitle11", nullvalue = null } }.Save();
|
||||
new S_SysConfig<TestConfig> { Name = "testkey22", Config = new TestConfig { clicks = 22, title = "testtitle22" } }.Save();
|
||||
new S_SysConfig<TestConfig> { Name = "testkey33", Config = new TestConfig { clicks = 33, title = "testtitle33" } }.Save();
|
||||
var testconfigs11 = S_SysConfig<TestConfig>.Select.ToList();
|
||||
@ -136,7 +140,7 @@ namespace base_entity
|
||||
|
||||
}).Wait();
|
||||
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("按任意键结束。。。");
|
||||
Console.ReadKey();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -13,7 +13,9 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
|
||||
<DefineConstants>NETCORE30</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.BaseEntity\FreeSql.Extensions.BaseEntity.csproj" />
|
||||
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.JsonMap\FreeSql.Extensions.JsonMap.csproj" />
|
||||
|
Reference in New Issue
Block a user