本文整理汇总了C#中System.Linq.Expressions.Expression.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.IsNull方法的具体用法?C# Expression.IsNull怎么用?C# Expression.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.IsNull方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PolymorphicEqual
public static Expression PolymorphicEqual(Expression exp1, Expression exp2)
{
if (exp1.NodeType == ExpressionType.New || exp2.NodeType == ExpressionType.New)
{
if (exp1.IsNull() || exp2.IsNull())
return Expression.Constant(false);
exp1 = ConstanToNewExpression(exp1) ?? exp1;
exp2 = ConstanToNewExpression(exp2) ?? exp2;
return (exp1 as NewExpression).Arguments.ZipStrict(
(exp2 as NewExpression).Arguments, (o, i) => SmartEqualizer.PolymorphicEqual(o, i)).AggregateAnd();
}
Expression result;
result = PrimaryKeyEquals(exp1, exp2);
if (result != null)
return result;
result = ObjectEquals(exp1, exp2);
if (result != null)
return result;
result = ConditionalEquals(exp1, exp2);
if (result != null)
return result;
result = CoalesceEquals(exp1, exp2);
if (result != null)
return result;
result = LiteEquals(exp1, exp2);
if (result != null)
return result;
result = EntityEquals(exp1, exp2);
if (result != null)
return result;
result = TypeEquals(exp1, exp2);
if (result != null)
return result;
result = MListElementEquals(exp1, exp2);
if (result != null)
return result;
return EqualNullable(exp1, exp2);
}
示例2: EntityEquals
public static Expression EntityEquals(Expression e1, Expression e2)
{
e1 = ConstantToEntity(e1) ?? e1;
e2 = ConstantToEntity(e2) ?? e2;
if (e1 is EmbeddedEntityExpression && e2.IsNull())
return EmbeddedNullEquals((EmbeddedEntityExpression)e1);
if (e2 is EmbeddedEntityExpression && e1.IsNull())
return EmbeddedNullEquals((EmbeddedEntityExpression)e2);
if (e1 is EntityExpression)
if (e2 is EntityExpression) return FieFieEquals((EntityExpression)e1, (EntityExpression)e2);
else if (e2 is ImplementedByExpression) return FieIbEquals((EntityExpression)e1, (ImplementedByExpression)e2);
else if (e2 is ImplementedByAllExpression) return FieIbaEquals((EntityExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return EqualsToNull(((EntityExpression)e1).ExternalId);
else return null;
else if (e1 is ImplementedByExpression)
if (e2 is EntityExpression) return FieIbEquals((EntityExpression)e2, (ImplementedByExpression)e1);
else if (e2 is ImplementedByExpression) return IbIbEquals((ImplementedByExpression)e1, (ImplementedByExpression)e2);
else if (e2 is ImplementedByAllExpression) return IbIbaEquals((ImplementedByExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return ((ImplementedByExpression)e1).Implementations.Select(a => EqualsToNull(a.Value.ExternalId)).AggregateAnd();
else return null;
else if (e1 is ImplementedByAllExpression)
if (e2 is EntityExpression) return FieIbaEquals((EntityExpression)e2, (ImplementedByAllExpression)e1);
else if (e2 is ImplementedByExpression) return IbIbaEquals((ImplementedByExpression)e2, (ImplementedByAllExpression)e1);
else if (e2 is ImplementedByAllExpression) return IbaIbaEquals((ImplementedByAllExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return EqualsToNull(((ImplementedByAllExpression)e1).TypeId.TypeColumn);
else return null;
else if (e1.IsNull())
if (e2 is EntityExpression) return EqualsToNull(((EntityExpression)e2).ExternalId);
else if (e2 is ImplementedByExpression) return ((ImplementedByExpression)e2).Implementations.Select(a => EqualsToNull(a.Value.ExternalId)).AggregateAnd();
else if (e2 is ImplementedByAllExpression) return EqualsToNull(((ImplementedByAllExpression)e2).TypeId.TypeColumn);
else if (e2.IsNull()) return True;
else return null;
else return null;
}
示例3: GetEntity
private static Expression GetEntity(Expression exp)
{
exp = ConstantToLite(exp) ?? exp;
if (exp.IsNull())
return Expression.Constant(null, exp.Type.CleanType());
var liteExp = exp as LiteReferenceExpression;
if (liteExp == null)
throw new InvalidCastException("Impossible to convert expression to Lite: {0}".FormatWith(exp.ToString()));
return liteExp.Reference;
}
示例4: MListElementEquals
public static Expression MListElementEquals(Expression e1, Expression e2)
{
if (e1 is MListElementExpression || e2 is MListElementExpression)
{
if (e1.IsNull())
return EqualsToNull(((MListElementExpression)e2).RowId);
if (e2.IsNull())
return EqualsToNull(((MListElementExpression)e1).RowId);
return EqualNullable(((MListElementExpression)e1).RowId, ((MListElementExpression)e2).RowId);
}
return null;
}
示例5: LiteEquals
public static Expression LiteEquals(Expression e1, Expression e2)
{
if ( e1.Type.IsLite() || e2.Type.IsLite())
{
if (!e1.Type.IsLite() && !e1.IsNull() || !e2.Type.IsLite() && !e2.IsNull())
throw new InvalidOperationException("Imposible to compare expressions of type {0} == {1}".FormatWith(e1.Type.TypeName(), e2.Type.TypeName()));
return PolymorphicEqual(GetEntity(e1), GetEntity(e2)); //Conditional and Coalesce could be inside
}
return null;
}
示例6: EntityEquals
public static Expression EntityEquals(Expression e1, Expression e2)
{
e1 = ConstantToEntity(e1) ?? e1;
e2 = ConstantToEntity(e2) ?? e2;
var tE1 = (DbExpressionType)e1.NodeType;
var tE2 = (DbExpressionType)e2.NodeType;
if (tE1 == DbExpressionType.EmbeddedInit && e2.IsNull())
return EmbeddedNullEquals((EmbeddedEntityExpression)e1);
if (tE2 == DbExpressionType.EmbeddedInit && e1.IsNull())
return EmbeddedNullEquals((EmbeddedEntityExpression)e2);
if (tE1 == DbExpressionType.Entity)
if (tE2 == DbExpressionType.Entity) return FieFieEquals((EntityExpression)e1, (EntityExpression)e2);
else if (tE2 == DbExpressionType.ImplementedBy) return FieIbEquals((EntityExpression)e1, (ImplementedByExpression)e2);
else if (tE2 == DbExpressionType.ImplementedByAll) return FieIbaEquals((EntityExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return EqualsToNull(((EntityExpression)e1).ExternalId);
else return null;
else if (tE1 == DbExpressionType.ImplementedBy)
if (tE2 == DbExpressionType.Entity) return FieIbEquals((EntityExpression)e2, (ImplementedByExpression)e1);
else if (tE2 == DbExpressionType.ImplementedBy) return IbIbEquals((ImplementedByExpression)e1, (ImplementedByExpression)e2);
else if (tE2 == DbExpressionType.ImplementedByAll) return IbIbaEquals((ImplementedByExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return ((ImplementedByExpression)e1).Implementations.Select(a => EqualsToNull(a.Value.ExternalId)).AggregateAnd();
else return null;
else if (tE1 == DbExpressionType.ImplementedByAll)
if (tE2 == DbExpressionType.Entity) return FieIbaEquals((EntityExpression)e2, (ImplementedByAllExpression)e1);
else if (tE2 == DbExpressionType.ImplementedBy) return IbIbaEquals((ImplementedByExpression)e2, (ImplementedByAllExpression)e1);
else if (tE2 == DbExpressionType.ImplementedByAll) return IbaIbaEquals((ImplementedByAllExpression)e1, (ImplementedByAllExpression)e2);
else if (e2.IsNull()) return EqualsToNull(((ImplementedByAllExpression)e1).Id);
else return null;
else if (e1.IsNull())
if (tE2 == DbExpressionType.Entity) return EqualsToNull(((EntityExpression)e2).ExternalId);
else if (tE2 == DbExpressionType.ImplementedBy) return ((ImplementedByExpression)e2).Implementations.Select(a => EqualsToNull(a.Value.ExternalId)).AggregateAnd();
else if (tE2 == DbExpressionType.ImplementedByAll) return EqualsToNull(((ImplementedByAllExpression)e2).Id);
else if (e2.IsNull()) return True;
else return null;
else return null;
}