コード例 #1
0
 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)
                                                                                )));
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        static Expression EntityIbEquals(EntityExpression ee, ImplementedByExpression ib)
        {
            var imp = ib.Implementations.TryGetC(ee.Type);

            if (imp == null)
            {
                return(False);
            }

            return(EntityEntityEquals(imp, ee));
        }
コード例 #7
0
ファイル: QueryFormatter.cs プロジェクト: nuub666/framework
 protected override Expression VisitImplementedBy(ImplementedByExpression reference)
 {
     throw InvalidSqlExpression(reference);
 }
コード例 #8
0
        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());
        }
コード例 #9
0
 protected internal override Expression VisitImplementedBy(ImplementedByExpression reference)
 {
     throw InvalidSqlExpression(reference);
 }
コード例 #10
0
 protected virtual bool CompareImplementedBy(ImplementedByExpression a, ImplementedByExpression b)
 {
     return(CompareDictionaries(a.Implementations, b.Implementations, Compare));
 }
コード例 #11
0
        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());
        }
コード例 #12
0
        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; 
        }
コード例 #13
0
ファイル: SmartEqualizer.cs プロジェクト: nuub666/framework
        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();
        }
コード例 #14
0
 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));
 }
コード例 #15
0
        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;
        }
コード例 #16
0
ファイル: SmartEqualizer.cs プロジェクト: rondoo/framework
        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();
        }
コード例 #17
0
ファイル: SmartEqualizer.cs プロジェクト: rondoo/framework
        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();
        }
コード例 #18
0
ファイル: SmartEqualizer.cs プロジェクト: rondoo/framework
        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); 
        }