mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
update demo
This commit is contained in:
parent
930f8f46e9
commit
a4dca34547
@ -1877,41 +1877,42 @@ var sql11111 = fsql.Select<Class1111>()
|
|||||||
}).Where(a => a.ConcurrentDictionarys.Length > 0).ToArray();
|
}).Where(a => a.ConcurrentDictionarys.Length > 0).ToArray();
|
||||||
|
|
||||||
#region pgsql poco
|
#region pgsql poco
|
||||||
//fsql.Aop.ParseExpression += (_, e) =>
|
fsql.Aop.ParseExpression += (_, e) =>
|
||||||
//{
|
{
|
||||||
// //解析 POCO Jsonb a.Customer.Name
|
if (e.Expression.IsParameter() == false) return;
|
||||||
// if (e.Expression is MemberExpression memExp)
|
//解析 POCO Jsonb a.Customer.Name
|
||||||
// {
|
if (e.Expression is MemberExpression memExp)
|
||||||
// var parentMemExps = new Stack<MemberExpression>();
|
{
|
||||||
// parentMemExps.Push(memExp);
|
var parentMemExps = new Stack<MemberExpression>();
|
||||||
// while (true)
|
parentMemExps.Push(memExp);
|
||||||
// {
|
while (true)
|
||||||
// switch (memExp.Expression.NodeType)
|
{
|
||||||
// {
|
switch (memExp.Expression.NodeType)
|
||||||
// case ExpressionType.MemberAccess:
|
{
|
||||||
// memExp = memExp.Expression as MemberExpression;
|
case ExpressionType.MemberAccess:
|
||||||
// if (memExp == null) return;
|
memExp = memExp.Expression as MemberExpression;
|
||||||
// parentMemExps.Push(memExp);
|
if (memExp == null) return;
|
||||||
// break;
|
parentMemExps.Push(memExp);
|
||||||
// case ExpressionType.Parameter:
|
break;
|
||||||
// var tb = fsql.CodeFirst.GetTableByEntity(memExp.Expression.Type);
|
case ExpressionType.Parameter:
|
||||||
// if (tb == null) return;
|
var tb = fsql.CodeFirst.GetTableByEntity(memExp.Expression.Type);
|
||||||
// if (tb.ColumnsByCs.TryGetValue(parentMemExps.Pop().Member.Name, out var trycol) == false) return;
|
if (tb == null) return;
|
||||||
// if (new[] { typeof(JToken), typeof(JObject), typeof(JArray) }.Contains(trycol.Attribute.MapType.NullableTypeOrThis()) == false) return;
|
if (tb.ColumnsByCs.TryGetValue(parentMemExps.Pop().Member.Name, out var trycol) == false) return;
|
||||||
// var tmpcol = tb.ColumnsByPosition.OrderBy(a => a.Attribute.Name.Length).First();
|
if (new[] { typeof(JToken), typeof(JObject), typeof(JArray) }.Contains(trycol.Attribute.MapType.NullableTypeOrThis()) == false) return;
|
||||||
// var result = e.FreeParse(Expression.MakeMemberAccess(memExp.Expression, tb.Properties[tmpcol.CsName]));
|
var tmpcol = tb.ColumnsByPosition.OrderBy(a => a.Attribute.Name.Length).First();
|
||||||
// result = result.Replace(tmpcol.Attribute.Name, trycol.Attribute.Name);
|
var result = e.FreeParse(Expression.MakeMemberAccess(memExp.Expression, tb.Properties[tmpcol.CsName]));
|
||||||
// while (parentMemExps.Any())
|
result = result.Replace(tmpcol.Attribute.Name, trycol.Attribute.Name);
|
||||||
// {
|
while (parentMemExps.Any())
|
||||||
// memExp = parentMemExps.Pop();
|
{
|
||||||
// result = $"{result}->>'{memExp.Member.Name}'";
|
memExp = parentMemExps.Pop();
|
||||||
// }
|
result = $"{result}->>'{memExp.Member.Name}'";
|
||||||
// e.Result = result;
|
}
|
||||||
// return;
|
e.Result = result;
|
||||||
// }
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//void RegisterPocoType(Type pocoType)
|
//void RegisterPocoType(Type pocoType)
|
||||||
//{
|
//{
|
||||||
@ -1951,7 +1952,7 @@ var sql11111 = fsql.Select<Class1111>()
|
|||||||
// .ToSql();
|
// .ToSql();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fsql.Aop.AuditValue += new EventHandler<FreeSql.Aop.AuditValueEventArgs>((_, e) =>
|
fsql.Aop.AuditValue += new EventHandler<FreeSql.Aop.AuditValueEventArgs>((_, e) =>
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,7 @@ namespace FreeSql.Tests.Issues
|
|||||||
RegisterPocoType(typeof(Customer)); //注删 POCO 类型
|
RegisterPocoType(typeof(Customer)); //注删 POCO 类型
|
||||||
fsql.Aop.ParseExpression += (_, e) =>
|
fsql.Aop.ParseExpression += (_, e) =>
|
||||||
{
|
{
|
||||||
|
if (e.Expression.IsParameter() == false) return;
|
||||||
//解析 POCO Jsonb a.Customer.Name
|
//解析 POCO Jsonb a.Customer.Name
|
||||||
if (e.Expression is MemberExpression memExp)
|
if (e.Expression is MemberExpression memExp)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user