A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/signumsoftware/framework/commit/644151a2481307fdbb53216d2d71022a71e75d2c below:

add support for IsNew and GetType in LINQ provider and LambdaToJavasc… · signumsoftware/framework@644151a · GitHub

@@ -1487,6 +1487,26 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment assig

1487 1487

return assignment;

1488 1488

}

1489 1489 1490 +

protected override Expression VisitConditional(ConditionalExpression c) // a.IsNew

1491 +

{

1492 +

Expression test = this.Visit(c.Test);

1493 +

if (test is ConstantExpression co)

1494 +

{

1495 +

if ((bool)co.Value!)

1496 +

return this.Visit(c.IfTrue);

1497 +

else

1498 +

return this.Visit(c.IfFalse);

1499 +

}

1500 + 1501 +

Expression ifTrue = this.Visit(c.IfTrue);

1502 +

Expression ifFalse = this.Visit(c.IfFalse);

1503 +

if (test != c.Test || ifTrue != c.IfTrue || ifFalse != c.IfFalse)

1504 +

{

1505 +

return Expression.Condition(test, ifTrue, ifFalse);

1506 +

}

1507 +

return c;

1508 +

}

1509 + 1490 1510

protected override Expression VisitMember(MemberExpression m)

1491 1511

{

1492 1512

Expression ex = base.VisitMember(m);

@@ -1539,6 +1559,7 @@ public Expression BindMethodCall(MethodCallExpression m)

1539 1559

return result;

1540 1560

}

1541 1561 1562 + 1542 1563

if (source is ImplementedByExpression ib)

1543 1564

{

1544 1565

if (m.Method.IsExtensionMethod())

@@ -1625,9 +1646,39 @@ public Expression BindMethodCall(MethodCallExpression m)

1625 1646

return tablePeriod;

1626 1647

}

1627 1648 1649 +

Expression PartialEval(Expression ee)

1650 +

{

1651 +

if (m.Method.IsExtensionMethod())

1652 +

{

1653 +

return ExpressionEvaluator.PartialEval(Expression.Call(null, m.Method, m.Arguments.Skip(1).PreAnd(ee)));

1654 +

}

1655 +

else

1656 +

{

1657 +

return ExpressionEvaluator.PartialEval(Expression.Call(ee, m.Method, m.Arguments));

1658 +

}

1659 +

}

1660 + 1661 +

if (source is TypeEntityExpression type)

1662 +

{

1663 +

return Condition(Expression.NotEqual(type.ExternalId, NullId(type.ExternalId.ValueType)),

1664 +

ifTrue: PartialEval(Expression.Constant(type.TypeValue)),

1665 +

ifFalse: Expression.Constant(null, m.Type));

1666 +

}

1667 + 1668 +

if(source is TypeImplementedByExpression typeIB)

1669 +

{

1670 +

return typeIB.TypeImplementations.Aggregate(

1671 +

(Expression)Expression.Constant(null, m.Type),

1672 +

(acum, kvp) => Condition(Expression.NotEqual(kvp.Value, NullId(kvp.Value.Value.Type)),

1673 +

ifTrue: PartialEval(Expression.Constant(kvp.Key)),

1674 +

ifFalse: acum));

1675 +

}

1676 + 1628 1677

return m;

1629 1678

}

1630 1679 1680 + 1681 + 1631 1682 1632 1683

private ConditionalExpression DispatchConditional(MethodCallExpression m, Expression test, Expression ifTrue, Expression ifFalse)

1633 1684

{

@@ -1748,6 +1799,9 @@ public Expression BindMemberAccess(MemberExpression m)

1748 1799

if (pi != null && ReflectionTools.PropertyEquals(pi, EntityExpression.IdOrNullProperty))

1749 1800

return ee.ExternalId;

1750 1801 1802 +

if (m.Member.Name == nameof(Entity.IsNew))

1803 +

return Expression.Constant(false);

1804 + 1751 1805

FieldInfo? fi = m.Member as FieldInfo ?? Reflector.TryFindFieldInfo(ee.Type, pi!);

1752 1806 1753 1807

if (fi == null)

@@ -1862,6 +1916,25 @@ public Expression BindMemberAccess(MemberExpression m)

1862 1916

_ => throw new InvalidOperationException("The member {0} of MListElement is not accesible on queries".FormatWith(m.Member)),

1863 1917

};

1864 1918

}

1919 +

case DbExpressionType.TypeEntity:

1920 +

{

1921 +

TypeEntityExpression type = (TypeEntityExpression)source;

1922 + 1923 +

return Condition(Expression.NotEqual(type.ExternalId, NullId(type.ExternalId.ValueType)),

1924 +

ifTrue: ExpressionEvaluator.PartialEval(Expression.MakeMemberAccess(Expression.Constant(type.TypeValue), m.Member)),

1925 +

ifFalse: Expression.Constant(null, m.Type));

1926 +

}

1927 + 1928 +

case DbExpressionType.TypeImplementedBy:

1929 +

{

1930 +

TypeImplementedByExpression typeIB = (TypeImplementedByExpression)source;

1931 + 1932 +

return typeIB.TypeImplementations.Aggregate(

1933 +

(Expression)Expression.Constant(null, m.Type),

1934 +

(acum, kvp) => Condition(Expression.NotEqual(kvp.Value, NullId(kvp.Value.Value.Type)),

1935 +

ifTrue: ExpressionEvaluator.PartialEval(Expression.MakeMemberAccess(Expression.Constant(kvp.Key), m.Member)),

1936 +

ifFalse: acum));

1937 +

}

1865 1938

}

1866 1939

}

1867 1940

break;

@@ -3477,6 +3550,7 @@ protected override Expression VisitConditional(ConditionalExpression c)

3477 3550

var ifTrue = Visit(c.IfTrue);

3478 3551

var ifFalse = Visit(c.IfFalse);

3479 3552 3553 + 3480 3554

if (colExpression is LiteReferenceExpression)

3481 3555

{

3482 3556

return Combiner<LiteReferenceExpression>(ifTrue, ifFalse, (col, l, r) =>


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4