Update Demo

This commit is contained in:
sunkaixuan 2023-09-10 19:49:16 +08:00
parent 72d17ad240
commit a6e3868dff
3 changed files with 49 additions and 12 deletions

View File

@ -0,0 +1,33 @@
using Npgsql;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Test;
namespace Test
{
partial class Program
{
public static void DynamicLinq(ISqlSugarClient db)
{
//程序启动时注册
StaticConfig.DynamicExpressionParserType = typeof(DynamicExpressionParser);
db.QueryFilter
.AddTableFilter(typeof(Order), "it", $" it.Name={ "jack" } ")
.AddTableFilter(typeof(Order), "it", $" it.Id={1} ");
db.Queryable<Order>().ToList();
}
}
}

View File

@ -5,6 +5,10 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj" />
</ItemGroup>

View File

@ -9,23 +9,23 @@ namespace Test
static void Main(string[] args)
{
JsonClient jsonToSqlClient = new JsonClient();
//jsonToSqlClient.Context = new SqlSugarClient(new ConnectionConfig()
//{
// DbType = DbType.SqlServer,
// IsAutoCloseConnection = true,
// ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST"
//});
jsonToSqlClient.Context = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.MySql,
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql"
}); ;
TestHelper.InitDatabase(jsonToSqlClient);
ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST"
});
//jsonToSqlClient.Context = new SqlSugarClient(new ConnectionConfig()
//{
// DbType = DbType.MySql,
// IsAutoCloseConnection = true,
// ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql"
//}); ;
//TestHelper.InitDatabase(jsonToSqlClient);
jsonToSqlClient.Context.Aop.OnLogExecuted = (sql, p) =>
{
Console.WriteLine(sql);
Console.WriteLine(UtilMethods.GetNativeSql(sql,p));
};
Insetable01(jsonToSqlClient);
@ -44,7 +44,7 @@ namespace Test
Updateable01(jsonToSqlClient);
Deleteable01(jsonToSqlClient);
DynamicLinq(jsonToSqlClient.Context);
Console.WriteLine();
}
}