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 EntityIbaEquals(EntityExpression ee, ImplementedByAllExpression iba) { return(Expression.And( ee.ExternalId.Value == NewId ? False : EqualNullable(new SqlCastExpression(typeof(string), ee.ExternalId.Value), iba.Id), EqualNullable(QueryBinder.TypeConstant(ee.Type), iba.TypeId.TypeColumn.Value)) .And(ee.ExternalPeriod.Overlaps(iba.ExternalPeriod))); }
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 VisitImplementedByAll(ImplementedByAllExpression iba) { var id = Visit(iba.Id); var typeId = (TypeImplementedByAllExpression)Visit(iba.TypeId); if (id != iba.Id || typeId != iba.TypeId) { return(new ImplementedByAllExpression(iba.Type, id, typeId)); } return(iba); }
protected internal override Expression VisitImplementedByAll(ImplementedByAllExpression reference) { throw InvalidSqlExpression(reference); }
protected virtual bool CompareImplementedByAll(ImplementedByAllExpression a, ImplementedByAllExpression b) { return(Compare(a.TypeId, b.TypeId) && Compare(a.Id, b.Id)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id) { Expression result = new ImplementedByAllExpression(IsLite ? Lite.Extract(FieldType) : FieldType, new ColumnExpression(Column.Type, tableAlias, Column.Name), new TypeImplementedByAllExpression(new PrimaryKeyExpression(new ColumnExpression(ColumnType.Type.Nullify(), tableAlias, ColumnType.Name)))); if (this.IsLite) return binder.MakeLite(result, null); else return result; }
protected internal override Expression VisitImplementedByAll(ImplementedByAllExpression rba) { return(Expression.Call(retriever, miRequestIBA.MakeGenericMethod(rba.Type), Visit(NullifyColumn(rba.TypeId.TypeColumn)), Visit(NullifyColumn(rba.Id)))); }
static Expression FieIbaEquals(EntityExpression ee, ImplementedByAllExpression iba) { return Expression.And(EqualNullable(ee.ExternalId, iba.Id), EqualNullable(QueryBinder.TypeConstant(ee.Type), iba.TypeId.TypeColumn)); }
private ImplementedByAllExpression CombineIBA(ImplementedByAllExpression a, ImplementedByAllExpression b, Type type, Func <Expression, Expression, Expression> combiner) { return(new ImplementedByAllExpression(type, combiner(a.Id, b.Id), new TypeImplementedByAllExpression(new PrimaryKeyExpression(combiner(a.TypeId.TypeColumn, b.TypeId.TypeColumn))), null)); }
static Expression IbaIbaEquals(ImplementedByAllExpression iba, ImplementedByAllExpression iba2) { return Expression.And(EqualNullable(iba.Id, iba2.Id), EqualNullable(iba.TypeId.TypeColumn.Value, iba2.TypeId.TypeColumn.Value)); }
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 FieIbaEquals(EntityExpression ee, ImplementedByAllExpression iba) { return Expression.And( ee.ExternalId.Value == NewId ? False : EqualNullable(new SqlCastExpression(typeof(string), ee.ExternalId.Value), iba.Id), EqualNullable(QueryBinder.TypeConstant(ee.Type), iba.TypeId.TypeColumn.Value)); }
protected virtual Expression VisitImplementedByAll(ImplementedByAllExpression iba) { var id = Visit(iba.Id); var typeId = (TypeImplementedByAllExpression)Visit(iba.TypeId); if (id != iba.Id || typeId != iba.TypeId) return new ImplementedByAllExpression(iba.Type, id, typeId); return iba; }
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(); }
static Expression IbaIbaEquals(ImplementedByAllExpression iba, ImplementedByAllExpression iba2) { return(Expression.And(EqualNullable(iba.Id, iba2.Id), EqualNullable(iba.TypeId.TypeColumn.Value, iba2.TypeId.TypeColumn.Value))); }
protected override Expression VisitImplementedByAll(ImplementedByAllExpression reference) { throw InvalidSqlExpression(reference); }