@@ -1666,6 +1666,38 @@ public Expression BindMethodCall(MethodCallExpression m)
1666
1666
return tablePeriod;
1667
1667
}
1668
1668
1669
+
if(m.Method.DeclaringType == typeof(TypeEntityExtensions) && m.Method.Name == nameof(TypeEntityExtensions.ToTypeEntity))
1670
+
{
1671
+
var arg = m.Arguments[0];
1672
+
1673
+
1674
+
if (arg is TypeEntityExpression type)
1675
+
{
1676
+
var id = Condition(Expression.NotEqual(type.ExternalId, NullId(type.ExternalId.ValueType)),
1677
+
ifTrue: Expression.Constant(TypeLogic.TypeToId.GetOrThrow(type.TypeValue).Object),
1678
+
ifFalse: Expression.Constant(null, PrimaryKey.Type(typeof(TypeEntity)).Nullify()));
1679
+
1680
+
return new EntityExpression(typeof(TypeEntity), new PrimaryKeyExpression(id), null, null, null, null, null, false);
1681
+
}
1682
+
1683
+
if (arg is TypeImplementedByExpression typeIB)
1684
+
{
1685
+
var id = typeIB.TypeImplementations.Aggregate(
1686
+
(Expression)Expression.Constant(null, PrimaryKey.Type(typeof(TypeEntity)).Nullify()),
1687
+
(acum, kvp) => Condition(Expression.NotEqual(kvp.Value, NullId(kvp.Value.Value.Type)),
1688
+
ifTrue: Expression.Constant(TypeLogic.TypeToId.GetOrThrow(kvp.Key).Object),
1689
+
ifFalse: acum));
1690
+
1691
+
return new EntityExpression(typeof(TypeEntity), new PrimaryKeyExpression(id), null, null, null, null, null, false);
1692
+
}
1693
+
1694
+
if (arg is TypeImplementedByAllExpression typeIBA)
1695
+
{
1696
+
return new EntityExpression(typeof(TypeEntity), typeIBA.TypeColumn, null, null, null, null, null, false);
1697
+
}
1698
+
1699
+
}
1700
+
1669
1701
Expression PartialEval(Expression ee)
1670
1702
{
1671
1703
if (m.Method.IsExtensionMethod())
@@ -1678,20 +1710,22 @@ Expression PartialEval(Expression ee)
1678
1710
}
1679
1711
}
1680
1712
1681
-
if (source is TypeEntityExpression type)
1682
1713
{
1683
-
return Condition(Expression.NotEqual(type.ExternalId, NullId(type.ExternalId.ValueType)),
1684
-
ifTrue: PartialEval(Expression.Constant(type.TypeValue)),
1685
-
ifFalse: Expression.Constant(null, m.Type));
1686
-
}
1714
+
if (source is TypeEntityExpression type)
1715
+
{
1716
+
return Condition(Expression.NotEqual(type.ExternalId, NullId(type.ExternalId.ValueType)),
1717
+
ifTrue: PartialEval(Expression.Constant(type.TypeValue)),
1718
+
ifFalse: Expression.Constant(null, m.Type));
1719
+
}
1687
1720
1688
-
if(source is TypeImplementedByExpression typeIB)
1689
-
{
1690
-
return typeIB.TypeImplementations.Aggregate(
1691
-
(Expression)Expression.Constant(null, m.Type),
1692
-
(acum, kvp) => Condition(Expression.NotEqual(kvp.Value, NullId(kvp.Value.Value.Type)),
1693
-
ifTrue: PartialEval(Expression.Constant(kvp.Key)),
1694
-
ifFalse: acum));
1721
+
if (source is TypeImplementedByExpression typeIB)
1722
+
{
1723
+
return typeIB.TypeImplementations.Aggregate(
1724
+
(Expression)Expression.Constant(null, m.Type),
1725
+
(acum, kvp) => Condition(Expression.NotEqual(kvp.Value, NullId(kvp.Value.Value.Type)),
1726
+
ifTrue: PartialEval(Expression.Constant(kvp.Key)),
1727
+
ifFalse: acum));
1728
+
}
1695
1729
}
1696
1730
1697
1731
return m;
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