コード例 #1
0
        internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
        {
            Debug.Assert(outputMember.LeafEdmMember != null, "Constant can't correspond to an empty member path.");
            TypeUsage modelTypeUsage = Helper.GetModelTypeUsage(outputMember.LeafEdmMember);

            return(modelTypeUsage.Constant(m_scalar));
        }
コード例 #2
0
        private DbExpression GenerateValueExpression(
            EdmProperty property,
            PropagatorResult value)
        {
            if (value.IsNull)
            {
                return((DbExpression)Helper.GetModelTypeUsage((EdmMember)property).Null());
            }
            object obj = this.m_translator.KeyManager.GetPrincipalValue(value);

            if (Convert.IsDBNull(obj))
            {
                return((DbExpression)Helper.GetModelTypeUsage((EdmMember)property).Null());
            }
            TypeUsage modelTypeUsage = Helper.GetModelTypeUsage((EdmMember)property);
            Type      type           = obj.GetType();

            if (type.IsEnum())
            {
                obj = Convert.ChangeType(obj, type.GetEnumUnderlyingType(), (IFormatProvider)CultureInfo.InvariantCulture);
            }
            Type clrEquivalentType = ((PrimitiveType)modelTypeUsage.EdmType).ClrEquivalentType;

            if (type != clrEquivalentType)
            {
                obj = Convert.ChangeType(obj, clrEquivalentType, (IFormatProvider)CultureInfo.InvariantCulture);
            }
            return((DbExpression)modelTypeUsage.Constant(obj));
        }