private ImplementedByExpression CombineIB(ImplementedByExpression a, ImplementedByExpression b, Type type, Func <Expression, Expression, Expression> combiner) { return(new ImplementedByExpression(type, a.Strategy, a.Implementations.OuterJoinDictionaryCC(b.Implementations, (t, ia, ib) => CombineEntity(ia ?? NullEntity(t), ib ?? NullEntity(t), t, combiner) ))); }
static Expression EntityIn(Expression newItem, Dictionary <Type, PrimaryKey[]> entityIDs) { EntityExpression ee = newItem as EntityExpression; if (ee != null) { return(InPrimaryKey(ee.ExternalId, entityIDs.TryGetC(ee.Type) ?? new PrimaryKey[0])); } ImplementedByExpression ib = newItem as ImplementedByExpression; if (ib != null) { return(ib.Implementations.JoinDictionary(entityIDs, (t, f, values) => Expression.And(DbExpressionNominator.FullNominate(NotEqualToNull(f.ExternalId)), InPrimaryKey(f.ExternalId, values))) .Values.AggregateOr()); } ImplementedByAllExpression iba = newItem as ImplementedByAllExpression; if (iba != null) { return(entityIDs.Select(kvp => Expression.And( EqualNullable(new PrimaryKeyExpression(QueryBinder.TypeConstant(kvp.Key).Nullify()), iba.TypeId.TypeColumn), InPrimaryKey(iba.Id, kvp.Value))).AggregateOr()); } throw new InvalidOperationException("EntityIn not defined for newItem of type {0}".FormatWith(newItem.Type.Name)); }
static Expression IbIbaEquals(ImplementedByExpression ib, ImplementedByAllExpression iba) { var list = ib.Implementations.Values.Select(i => Expression.And( i.ExternalId.Value == NewId ? (Expression)False : EqualNullable(iba.Id, new SqlCastExpression(typeof(string), i.ExternalId.Value)), EqualNullable(iba.TypeId.TypeColumn.Value, QueryBinder.TypeConstant(i.Type)))).ToList(); return(list.AggregateOr()); }
protected internal virtual Expression VisitImplementedBy(ImplementedByExpression ib) { var implementations = Visit(ib.Implementations, v => (EntityExpression)Visit(v)); if (implementations != ib.Implementations) { return(new ImplementedByExpression(ib.Type, ib.Strategy, implementations)); } return(ib); }
static Expression FieIbEquals(EntityExpression ee, ImplementedByExpression ib) { var imp = ib.Implementations.TryGetC(ee.Type); if (imp == null) { return(False); } return(EqualNullable(imp.ExternalId.Value, ee.ExternalId.Value)); }
static Expression EntityIbEquals(EntityExpression ee, ImplementedByExpression ib) { var imp = ib.Implementations.TryGetC(ee.Type); if (imp == null) { return(False); } return(EntityEntityEquals(imp, ee)); }
protected override Expression VisitImplementedBy(ImplementedByExpression reference) { throw InvalidSqlExpression(reference); }
static Expression IbIbEquals(ImplementedByExpression ib, ImplementedByExpression ib2) { var list = ib.Implementations.JoinDictionary(ib2.Implementations, (t, i, j) => EqualNullable(i.ExternalId.Value, j.ExternalId.Value)).Values.ToList(); return(list.AggregateOr()); }
protected internal override Expression VisitImplementedBy(ImplementedByExpression reference) { throw InvalidSqlExpression(reference); }
protected virtual bool CompareImplementedBy(ImplementedByExpression a, ImplementedByExpression b) { return(CompareDictionaries(a.Implementations, b.Implementations, Compare)); }
static Expression IbIbEquals(ImplementedByExpression ib, ImplementedByExpression ib2) { var list = ib.Implementations.JoinDictionary(ib2.Implementations, (t, i, j) => EntityEntityEquals(i, j)).Values.ToList(); return(list.AggregateOr()); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id) { var implementations = ImplementationColumns.SelectDictionary(t => t, (t, ic) => new EntityExpression(t, new PrimaryKeyExpression(new ColumnExpression(ic.Type.Nullify(), tableAlias, ic.Name)), null, null, null, AvoidExpandOnRetrieving)); var result = new ImplementedByExpression(IsLite ? Lite.Extract(FieldType) : FieldType, SplitStrategy, implementations); if (this.IsLite) return binder.MakeLite(result, null); else return result; }
static Expression IbIbaEquals(ImplementedByExpression ib, ImplementedByAllExpression iba) { var list = ib.Implementations.Values.Select(i => Expression.And( EqualNullable(iba.Id, i.ExternalId), EqualNullable(iba.TypeId.TypeColumn, QueryBinder.TypeConstant(i.Type)))).ToList(); return list.AggregateOr(); }
protected internal override Expression VisitImplementedBy(ImplementedByExpression rb) { return(rb.Implementations.Select(ee => new When(Visit(ee.Value.ExternalId).NotEqualsNulll(), Visit(ee.Value))).ToCondition(rb.Type)); }
protected virtual Expression VisitImplementedBy(ImplementedByExpression ib) { var implementations = ib.Implementations.NewIfChange(v => (EntityExpression)Visit(v)); if (implementations != ib.Implementations) return new ImplementedByExpression(ib.Type, ib.Strategy, implementations); return ib; }
static Expression IbIbaEquals(ImplementedByExpression ib, ImplementedByAllExpression iba) { var list = ib.Implementations.Values.Select(i => Expression.And( i.ExternalId.Value == NewId ? (Expression)False : EqualNullable(iba.Id, new SqlCastExpression(typeof(string), i.ExternalId.Value)), EqualNullable(iba.TypeId.TypeColumn.Value, QueryBinder.TypeConstant(i.Type)))).ToList(); return list.AggregateOr(); }
static Expression IbIbEquals(ImplementedByExpression ib, ImplementedByExpression ib2) { var list = ib.Implementations.JoinDictionary(ib2.Implementations, (t, i, j) => EqualNullable(i.ExternalId.Value, j.ExternalId.Value)).Values.ToList(); return list.AggregateOr(); }
static Expression FieIbEquals(EntityExpression ee, ImplementedByExpression ib) { var imp = ib.Implementations.TryGetC(ee.Type); if (imp == null) return False; return EqualNullable(imp.ExternalId.Value, ee.ExternalId.Value); }