Пример #1
0
 private static bool IsNullableValue(SqlMember m)
 {
     return(TypeSystem.IsNullableType(m.Expression.ClrType) && (m.Member.Name == "Value"));
 }
Пример #2
0
            private static bool CanDbConvert(Type from, Type to)
            {
                from = TypeSystem.GetNonNullableType(from);
                to   = TypeSystem.GetNonNullableType(to);
                if (from == to)
                {
                    return(true);
                }
                if (to.IsAssignableFrom(from))
                {
                    return(true);
                }
                TypeCode typeCode = Type.GetTypeCode(to);
                TypeCode code2    = Type.GetTypeCode(from);

                switch (typeCode)
                {
                case TypeCode.Int16:
                    return((code2 == TypeCode.Byte) || (code2 == TypeCode.SByte));

                case TypeCode.UInt16:
                    return((code2 == TypeCode.Byte) || (code2 == TypeCode.SByte));

                case TypeCode.Int32:
                    switch (code2)
                    {
                    case TypeCode.Byte:
                    case TypeCode.SByte:
                    case TypeCode.Int16:
                        return(true);
                    }
                    return(code2 == TypeCode.UInt16);

                case TypeCode.UInt32:
                    switch (code2)
                    {
                    case TypeCode.Byte:
                    case TypeCode.SByte:
                    case TypeCode.Int16:
                        return(true);
                    }
                    return(code2 == TypeCode.UInt16);

                case TypeCode.Int64:
                    switch (code2)
                    {
                    case TypeCode.Byte:
                    case TypeCode.SByte:
                    case TypeCode.Int16:
                    case TypeCode.UInt16:
                    case TypeCode.Int32:
                        return(true);
                    }
                    return(code2 == TypeCode.UInt32);

                case TypeCode.UInt64:
                    switch (code2)
                    {
                    case TypeCode.Byte:
                    case TypeCode.SByte:
                    case TypeCode.Int16:
                    case TypeCode.UInt16:
                    case TypeCode.Int32:
                        return(true);
                    }
                    return(code2 == TypeCode.UInt32);

                case TypeCode.Double:
                    return(code2 == TypeCode.Single);

                case TypeCode.Decimal:
                    if (code2 != TypeCode.Single)
                    {
                        return(code2 == TypeCode.Double);
                    }
                    return(true);
                }
                return(false);
            }
Пример #3
0
            public override Expression VisitMemberAccess(MemberExpression m)
            {
                if (MetaPosition.AreSameMember(m.Member, this.association.ThisMember.Member))
                {
                    Expression[] keyValues = GetKeyValues(this.Visit(m.Expression), this.association.ThisKey);
                    return(Translator.WhereClauseFromSourceAndKeys(this.otherSouce, this.association.OtherKey.ToArray <MetaDataMember>(), keyValues));
                }
                Expression expression = this.Visit(m.Expression);

                if (expression == m.Expression)
                {
                    return(m);
                }
                if (((expression.Type != m.Expression.Type) && (m.Member.Name == "Count")) && TypeSystem.IsSequenceType(expression.Type))
                {
                    return(Expression.Call(typeof(Enumerable), "Count", new Type[] { TypeSystem.GetElementType(expression.Type) }, new Expression[] { expression }));
                }
                return(Expression.MakeMemberAccess(expression, m.Member));
            }