protected internal override Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb) { return(typeIb.TypeImplementations.Reverse().Aggregate((Expression)NullType, (acum, imp) => Expression.Condition( Expression.NotEqual(Visit(NullifyColumn(imp.Value)), NullId), Expression.Constant(imp.Key, typeof(Type)), acum))); }
protected internal override Expression VisitLiteValue(LiteValueExpression lite) { var id = Visit(NullifyColumn(lite.Id)); if (id == null) { return(Expression.Constant(null, lite.Type)); } var toStr = Visit(lite.ToStr); var typeId = lite.TypeId; var toStringOrNull = toStr ?? Expression.Constant(null, typeof(string)); Expression nothing = Expression.Constant(null, lite.Type); Expression liteConstructor = null; if (typeId is TypeEntityExpression) { Type type = ((TypeEntityExpression)typeId).TypeValue; liteConstructor = Expression.Condition(Expression.NotEqual(id, NullId), Expression.Convert(Lite.NewExpression(type, id, toStringOrNull), lite.Type), nothing); } else if (typeId is TypeImplementedByExpression) { TypeImplementedByExpression tib = (TypeImplementedByExpression)typeId; liteConstructor = tib.TypeImplementations.Aggregate(nothing, (acum, ti) => { var visitId = Visit(NullifyColumn(ti.Value)); return(Expression.Condition(Expression.NotEqual(visitId, NullId), Expression.Convert(Lite.NewExpression(ti.Key, visitId, toStringOrNull), lite.Type), acum)); }); } else if (typeId is TypeImplementedByAllExpression) { TypeImplementedByAllExpression tiba = (TypeImplementedByAllExpression)typeId; var tid = Visit(NullifyColumn(tiba.TypeColumn)); liteConstructor = Expression.Convert(Expression.Call(miLiteCreateParse, Expression.Constant(Schema.Current), tid, id.UnNullify(), toStringOrNull), lite.Type); } else { liteConstructor = Expression.Condition(Expression.NotEqual(id.Nullify(), NullId), Expression.Convert(Expression.Call(miLiteCreate, Visit(typeId), id.UnNullify(), toStringOrNull), lite.Type), nothing); } if (toStr != null) { return(Expression.Call(retriever, miModifiablePostRetrieving.MakeGenericMethod(typeof(LiteImp)), liteConstructor.TryConvert(typeof(LiteImp))).TryConvert(liteConstructor.Type)); } else { return(Expression.Call(retriever, miRequestLite.MakeGenericMethod(Lite.Extract(lite.Type)), liteConstructor)); } }
private static Expression TypeIbIbEquals(TypeImplementedByExpression typeIb1, TypeImplementedByExpression typeIb2) { var joins = (from imp1 in typeIb1.TypeImplementations join imp2 in typeIb2.TypeImplementations on imp1.Key equals imp2.Key select Expression.And(NotEqualToNull(imp1.Value), NotEqualToNull(imp2.Value))).ToList(); return(joins.AggregateOr()); }
protected internal virtual Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb) { var implementations = Visit(typeIb.TypeImplementations, eid => (PrimaryKeyExpression)Visit(eid)); if (implementations != typeIb.TypeImplementations) { return(new TypeImplementedByExpression(implementations)); } return(typeIb); }
private static Expression TypeFieIbEquals(TypeEntityExpression typeFie, TypeImplementedByExpression typeIb) { var externalId = typeIb.TypeImplementations.TryGetC(typeFie.TypeValue); if (externalId == null) { return(False); } return(Expression.And(NotEqualToNull(typeFie.ExternalId), NotEqualToNull(externalId))); }
private static Expression TypeConstantIbEquals(ConstantExpression ce, TypeImplementedByExpression typeIb) { if (ce.IsNull()) { return(typeIb.TypeImplementations.Select(imp => EqualsToNull(imp.Value)).AggregateAnd()); } Type type = (Type)ce.Value; var externalId = typeIb.TypeImplementations.TryGetC(type); return(NotEqualToNull(externalId)); }
private bool IsCacheable(Expression newTypeId) { TypeEntityExpression tfie = newTypeId as TypeEntityExpression; if (tfie != null) { return(IsCached(tfie.TypeValue)); } TypeImplementedByExpression tibe = newTypeId as TypeImplementedByExpression; if (tibe != null) { return(tibe.TypeImplementations.All(t => IsCached(t.Key))); } return(false); }
private static Expression TypeIbIbaEquals(TypeImplementedByExpression typeIb, TypeImplementedByAllExpression typeIba) { return(typeIb.TypeImplementations .Select(imp => Expression.And(NotEqualToNull(imp.Value), EqualNullable(typeIba.TypeColumn, QueryBinder.TypeConstant(imp.Key)))) .AggregateOr()); }
protected internal override Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb) { throw InvalidSqlExpression(typeIb); }
protected virtual bool CompareTypeImplementedBy(TypeImplementedByExpression a, TypeImplementedByExpression b) { return(CompareDictionaries(a.TypeImplementations, b.TypeImplementations, Compare)); }
private static Expression TypeIbIbaEquals(TypeImplementedByExpression typeIb, TypeImplementedByAllExpression typeIba) { return typeIb.TypeImplementations .Select(imp => Expression.And(NotEqualToNull(imp.Value), EqualNullable(typeIba.TypeColumn, QueryBinder.TypeConstant(imp.Key)))) .AggregateOr(); }
private static Expression TypeIbIbEquals(TypeImplementedByExpression typeIb1, TypeImplementedByExpression typeIb2) { var joins = (from imp1 in typeIb1.TypeImplementations join imp2 in typeIb2.TypeImplementations on imp1.Key equals imp2.Key select Expression.And(NotEqualToNull(imp1.Value), NotEqualToNull(imp2.Value))).ToList(); return joins.AggregateOr(); }
private static Expression TypeFieIbEquals(TypeEntityExpression typeFie, TypeImplementedByExpression typeIb) { var externalId = typeIb.TypeImplementations.TryGetC(typeFie.TypeValue); if (externalId == null) return False; return Expression.And(NotEqualToNull(typeFie.ExternalId), NotEqualToNull(externalId)); }
private static Expression TypeConstantIbEquals(ConstantExpression ce, TypeImplementedByExpression typeIb) { if (ce.IsNull()) { return typeIb.TypeImplementations.Select(imp => EqualsToNull(imp.Value)).AggregateAnd(); } Type type = (Type)ce.Value; var externalId = typeIb.TypeImplementations.TryGetC(type); return NotEqualToNull(externalId); }
protected virtual Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb) { var implementations = typeIb.TypeImplementations.NewIfChange(eid => Visit(eid)); if (implementations != typeIb.TypeImplementations) return new TypeImplementedByExpression(implementations); return typeIb; }
protected override Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb) { throw InvalidSqlExpression(typeIb); }