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));
                }
            }
示例#3
0
        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());
        }
示例#4
0
        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);
        }
示例#5
0
        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)));
        }
示例#6
0
        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));
        }
示例#7
0
        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);
        }
示例#8
0
 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());
 }
示例#9
0
 protected internal override Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb)
 {
     throw InvalidSqlExpression(typeIb);
 }
示例#10
0
 protected virtual bool CompareTypeImplementedBy(TypeImplementedByExpression a, TypeImplementedByExpression b)
 {
     return(CompareDictionaries(a.TypeImplementations, b.TypeImplementations, Compare));
 }
示例#11
0
 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();
 }
示例#12
0
        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();
        }
示例#13
0
        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));
        }
示例#14
0
        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);
        }
示例#15
0
        protected virtual Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb)
        {
            var implementations = typeIb.TypeImplementations.NewIfChange(eid => Visit(eid));

            if (implementations != typeIb.TypeImplementations)
                return new TypeImplementedByExpression(implementations);
            return typeIb;
        }
示例#16
0
 protected override Expression VisitTypeImplementedBy(TypeImplementedByExpression typeIb)
 {
     throw InvalidSqlExpression(typeIb);
 }