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));
                }
            }
Exemple #2
0
        protected internal virtual Expression VisitLiteValue(LiteValueExpression lite)
        {
            var newTypeId = Visit(lite.TypeId);
            var newId     = Visit(lite.Id);
            var newToStr  = Visit(lite.ToStr);

            if (newTypeId != lite.TypeId || newId != lite.Id || newToStr != lite.ToStr)
            {
                return(new LiteValueExpression(lite.Type, newTypeId, newId, newToStr));
            }
            return(lite);
        }
 protected internal override Expression VisitLiteValue(LiteValueExpression lite)
 {
     throw InvalidSqlExpression(lite);
 }
Exemple #4
0
 protected virtual bool CompareLiteValue(LiteValueExpression a, LiteValueExpression b)
 {
     return(Compare(a.Id, b.Id) &&
            Compare(a.ToStr, b.ToStr) &&
            Compare(a.TypeId, b.TypeId));
 }
 protected virtual Expression VisitLiteValue(LiteValueExpression lite)
 {
     var newTypeId = Visit(lite.TypeId);
     var newId = Visit(lite.Id);
     var newToStr = Visit(lite.ToStr);
     if (newTypeId != lite.TypeId || newId != lite.Id || newToStr != lite.ToStr)
         return new LiteValueExpression(lite.Type, newTypeId, newId, newToStr);
     return lite;
 }
Exemple #6
0
 protected override Expression VisitLiteValue(LiteValueExpression lite)
 {
     throw InvalidSqlExpression(lite);
 }