Ejemplo n.º 1
0
 internal override SqlNode VisitMember(SqlMember m)
 {
     m.Expression = this.VisitExpression(m.Expression);
     if (IsNullableValue(m))
     {
         return(sql.UnaryValueOf(m.Expression, m.SourceExpression));
     }
     else if (IsNullableHasValue(m))
     {
         return(sql.Unary(SqlNodeType.IsNotNull, m.Expression, m.SourceExpression));
     }
     return(m);
 }
Ejemplo n.º 2
0
        internal SqlExpression BuildProjection(SqlExpression item, MetaType rowType, bool allowDeferred, SqlLink link, Expression source)
        {
            if (!rowType.HasInheritance)
            {
                return(this.BuildProjectionInternal(item, rowType, (rowType.Table != null) ? rowType.PersistentDataMembers : rowType.DataMembers, allowDeferred, link, source));
            }
            else
            {
                // Build a type case that represents a switch between the various type.
                List <MetaType>        mappedTypes = new List <MetaType>(rowType.InheritanceTypes);
                List <SqlTypeCaseWhen> whens       = new List <SqlTypeCaseWhen>();
                SqlTypeCaseWhen        @else       = null;

                MetaType       root          = rowType.InheritanceRoot;
                MetaDataMember discriminator = root.Discriminator;
                Type           dt            = discriminator.Type;
                SqlMember      dm            = sql.Member(item, discriminator.Member);

                foreach (MetaType type in mappedTypes)
                {
                    if (type.HasInheritanceCode)
                    {
                        SqlNew defaultProjection = this.BuildProjectionInternal(item, type, type.PersistentDataMembers, allowDeferred, link, source);
                        if (type.IsInheritanceDefault)
                        {
                            @else = new SqlTypeCaseWhen(null, defaultProjection);
                        }
                        // Add an explicit case even for the default.
                        // Redundant results will be optimized out later.
                        object        code  = InheritanceRules.InheritanceCodeForClientCompare(type.InheritanceCode, dm.SqlType);
                        SqlExpression match = sql.Value(dt, sql.Default(discriminator), code, true, source);
                        whens.Add(new SqlTypeCaseWhen(match, defaultProjection));
                    }
                }
                if (@else == null)
                {
                    throw Error.EmptyCaseNotSupported();
                }
                whens.Add(@else);   // Add the else at the end.

                return(sql.TypeCase(root.Type, root, dm, whens.ToArray(), source));
            }
        }
Ejemplo n.º 3
0
        internal static bool CanConvert(SqlNode node)
        {
            SqlBinary bo = node as SqlBinary;

            if (bo != null && (IsCompareToValue(bo) || IsVbCompareStringEqualsValue(bo)))
            {
                return(true);
            }
            SqlMember sm = node as SqlMember;

            if (sm != null && IsSupportedMember(sm))
            {
                return(true);
            }
            SqlMethodCall mc = node as SqlMethodCall;

            if (mc != null && (IsSupportedMethod(mc) || IsSupportedVbHelperMethod(mc)))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 internal virtual SqlNode VisitMember(SqlMember m)
 {
     m.Expression = this.VisitExpression(m.Expression);
     return(m);
 }
 internal override SqlNode VisitMember(SqlMember m)
 {
     return(new SqlMember(m.ClrType, m.SqlType, (SqlExpression)this.Visit(m.Expression), m.Member));
 }
Ejemplo n.º 6
0
 internal override SqlNode VisitMember(SqlMember m) => new SqlMember(m.ClrType, m.SqlType, (SqlExpression)Visit(m.Expression), m.Member);
Ejemplo n.º 7
0
 private static bool IsNullableHasValue(SqlMember m)
 {
     return(TypeSystem.IsNullableType(m.Expression.ClrType) && m.Member.Name == "HasValue");
 }
Ejemplo n.º 8
0
 private static bool IsSupportedMember(SqlMember m)
 {
     return(IsNullableHasValue(m) || IsNullableHasValue(m));
 }