System.Data.Common.CommandTrees.DbExpression.CastTo(System.Data.Metadata.Edm.TypeUsage)

Here are the examples of the csharp api class System.Data.Common.CommandTrees.DbExpression.CastTo(System.Data.Metadata.Edm.TypeUsage) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

11 Examples 7

1. Example

View license
protected virtual CqtExpression WrapNonCollectionOperand(ExpressionConverter parent, CqtExpression operand,
                    TypeUsage returnType)
                {
                    if (!TypeUsageEquals(returnType, operand.ResultType))
                    {
                        operand = operand.CastTo(returnType);
                    }
                    return operand;
                }

2. Example

View license
internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
        {
            DbExpression cqt = m_memberPath.AsCqt(row);

            TypeUsage outputMemberTypeUsage;
            if (NeedToCastCqlValue(outputMember, out outputMemberTypeUsage))
            {
                cqt = cqt.CastTo(outputMemberTypeUsage);
            }

            return cqt;
        }

3. Example

View license
private DbExpression GenerateScalarPropertyMappingView(EdmProperty edmProperty, EdmProperty columnProperty, DbExpression row)
        {
            DbExpression accessorExpr = GenerateColumnRef(row, columnProperty);
            if (!TypeSemantics.IsEqual(accessorExpr.ResultType, edmProperty.TypeUsage))
            {
                accessorExpr = accessorExpr.CastTo(edmProperty.TypeUsage);
            }
            return accessorExpr;
        }

4. Example

View license
private DbExpression AlignTypes(DbExpression cqt, Type toClrType)
        {
            Type fromClrType = null; // not used in this code path
            TypeUsage toType = GetCastTargetType(cqt.ResultType, toClrType, fromClrType, false);
            if (null != toType)
            {
                return cqt.CastTo(toType);
            }
            else
            {
                return cqt;
            }
        }

5. Example

View license
protected override CqtExpression WrapNonCollectionOperand(ExpressionConverter parent, CqtExpression operand, TypeUsage returnType)
                {
                    // always count a constant value
                    DbExpression constantExpression = DbExpressionBuilder.Constant(1);
                    if (!TypeUsageEquals(constantExpression.ResultType, returnType))
                    {
                        constantExpression = constantExpression.CastTo(returnType);
                    }
                    return constantExpression;
                }

6. Example

Project: referencesource
Source File: CTreeGenerator.cs
View license
public override DbExpression Visit(CastOp op, Node n)
        {
            // Direct conversion to DbCastExpression with the same Type and converted argument DbExpression
            return VisitChild(n, 0).CastTo(op.Type);
        }

7. Example

View license
private DbExpression CreateCastExpression(DbExpression source, Type toClrType, Type fromClrType)
        {
            // see if the source can be normalized as a set
            DbExpression setSource = NormalizeSetSource(source);
            if (!Object.ReferenceEquals(source, setSource))
            {
                // if the resulting cast is a no-op (no either kind is supported
                // for set sources), yield the source
                if (null == GetCastTargetType(setSource.ResultType, toClrType, fromClrType, true))
                {
                    return source;
                }
            }

            // try to find the appropriate target target for the cast
            TypeUsage toType = GetCastTargetType(source.ResultType, toClrType, fromClrType, true);
            if (null == toType)
            {
                // null indicates a no-op cast (from the perspective of the model)
                return source;
            }

            return source.CastTo(toType);
        }

8. Example

View license
protected virtual CqtExpression WrapCollectionOperand(ExpressionConverter parent, CqtExpression operand,
                    TypeUsage returnType)
                {
                    // check if the operand needs to be wrapped to ensure the correct function overload is called
                    if (!TypeUsageEquals(returnType, ((CollectionType)operand.ResultType.EdmType).TypeUsage))
                    {
                        DbExpressionBinding operandCastBinding = operand.BindAs(parent.AliasGenerator.Next());
                        DbProjectExpression operandCastProjection = operandCastBinding.Project(operandCastBinding.Variable.CastTo(returnType));
                        operand = operandCastProjection;
                    }
                    return operand;
                }

9. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpression CreateConstructorCallExpression(AST.MethodExpr methodExpr,
             /n ..... /n //View Source file for more details /n }

10. Example

View license
private DbExpression GenerateScalarResultMappingView(DbExpression storeFunctionInvoke)
        {
   /n ..... /n //View Source file for more details /n }

11. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static Dictionary<AST.BuiltInKind, BuiltInExprConverter> CreateBuiltInExprConverter()
/n ..... /n //View Source file for more details /n }