System.Data.Common.CommandTrees.DbExpression.BindAs(string)

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

37 Examples 7

1. Example

View license
protected override CqtExpression TranslatePagingOperator(ExpressionConverter parent, CqtExpression operand, CqtExpression count)
                {
                    return parent.Skip(operand.BindAs(parent.AliasGenerator.Next()), count);
                }

2. Example

View license
internal override CqtExpression Translate(ExpressionConverter parent, MethodCallExpression call)
                {
                    // Translate source
                    CqtExpression source = parent.TranslateSet(call.Arguments[0]);

                    // Figure out the type to cast to
                    Type toClrType = TypeSystem.GetElementType(call.Type);
                    Type fromClrType = TypeSystem.GetElementType(call.Arguments[0].Type);

                    // Get binding to the elements of the input source
                    DbExpressionBinding binding = source.BindAs(parent.AliasGenerator.Next());

                    CqtExpression cast = parent.CreateCastExpression(binding.Variable, toClrType, fromClrType);
                    return parent.Project(binding, cast);
                }

3. Example

Project: referencesource
Source File: UpdateCompiler.cs
View license
private static DbExpressionBinding GetTarget(TableChangeProcessor processor)
        {
            Debug.Assert(null != processor);

            // use a fixed var name since the command trees all have exactly one binding
            return processor.Table.Scan().BindAs(s_targetVarName);
        }

4. Example

View license
protected override CqtExpression TranslateOneLambda(ExpressionConverter parent, DbExpressionBinding sourceBinding, CqtExpression lambda)
                {
                    // elements of the inner selector should be used
                    lambda = parent.NormalizeSetSource(lambda);
                    DbExpressionBinding applyBinding = lambda.BindAs(parent.AliasGenerator.Next());
                    DbApplyExpression crossApply = sourceBinding.CrossApply(applyBinding);
                    return crossApply;
                }

5. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbProjectExpression RebindProject(DbExpression input, DbProjectExpression project)
                {
                    DbExpressionBinding inputBinding = input.BindAs(project.Input.VariableName);
                    return inputBinding.Project(project.Projection);
                }

6. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbFilterExpression RebindFilter(DbExpression input, DbFilterExpression filter)
                {
                    DbExpressionBinding inputBinding = input.BindAs(filter.Input.VariableName);
                    return inputBinding.Filter(filter.Predicate);
                }

7. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbSortExpression RebindSort(DbExpression input, DbSortExpression sort)
                {
                    DbExpressionBinding inputBinding = input.BindAs(sort.Input.VariableName);
                    return inputBinding.Sort(sort.SortOrder);
                }

8. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbSortExpression ApplySkipOrderToSort(DbExpression input, DbSkipExpression sortSpec)
                {
                    DbExpressionBinding inputBinding = input.BindAs(sortSpec.Input.VariableName);
                    return inputBinding.Sort(sortSpec.SortOrder);
                }

9. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbSkipExpression ApplySortOrderToSkip(DbExpression input, DbSortExpression sort, DbExpression k)
                {
                    DbExpressionBinding inputBinding = input.BindAs(sort.Input.VariableName);
                    return inputBinding.Skip(sort.SortOrder, k);
                }

10. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
protected DbSkipExpression RebindSkip(DbExpression input, DbSkipExpression skip, DbExpression k)
                {
                    DbExpressionBinding inputBinding = input.BindAs(skip.Input.VariableName);
                    return inputBinding.Skip(skip.SortOrder, k);
                }

11. Example

View license
private DbExpression TranslateLambda(LambdaExpression lambda, DbExpression input, out DbExpressionBinding binding)
        {
            input = NormalizeSetSource(input);

            // create binding context for this lambda expression
            binding = input.BindAs(_aliasGenerator.Next());

            return TranslateLambda(lambda, binding.Variable);
        }

12. Example

View license
private DbExpression TranslateLambda(LambdaExpression lambda, DbExpression input, string bindingName, out DbExpressionBinding binding)
        {
            input = NormalizeSetSource(input);

            // create binding context for this lambda expression
            binding = input.BindAs(bindingName);

            return TranslateLambda(lambda, binding.Variable);
        }

13. 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;
                }

14. Example

View license
protected override CqtExpression WrapCollectionOperand(ExpressionConverter parent, CqtExpression operand, TypeUsage returnType)
                {
                    // always count a constant value
                    DbProjectExpression constantProject = operand.BindAs(parent.AliasGenerator.Next()).Project(DbExpressionBuilder.Constant(1));
                    return constantProject;
                }

15. Example

View license
private static DbExpression ProcessResultSelector(ExpressionConverter parent, MethodCallExpression c/n ..... /n //View Source file for more details /n }

16. Example

View license
public override DbExpression Visit(DbFilterExpression expression)
            {
                // Only consider the Filter input
                DbExpression found = Find(expression.Input.Expression);
                if(!object.ReferenceEquals(found, expression.Input.Expression))
                {
                    return found.BindAs(expression.Input.VariableName).Filter(expression.Predicate);
                }
                else
                {
                    return expression;
                }
            }

17. Example

View license
public override DbExpression Visit(DbProjectExpression expression)
            {
                // Only allowed cases:
                // SELECT Deref(x) FROM <expression> AS x
                // SELECT x FROM <expression> as x
                DbExpression testExpr = expression.Projection;
                if (DbExpressionKind.Deref == testExpr.ExpressionKind)
                {
                    testExpr = ((DbDerefExpression)testExpr).Argument;
                }

                if (DbExpressionKind.VariableReference == testExpr.ExpressionKind)
                {
                    DbVariableReferenceExpression varRef = (DbVariableReferenceExpression)testExpr;
                    if (varRef.VariableName.Equals(expression.Input.VariableName, StringComparison.Ordinal))
                    {
                        DbExpression found = Find(expression.Input.Expression);
                        if (!object.ReferenceEquals(found, expression.Input.Expression))
                        {
                            return found.BindAs(expression.Input.VariableName).Project(expression.Projection);
                        }
                    }
                }

                return expression;
            }

18. Example

View license
public override DbExpression Visit(DbSortExpression expression)
            {
                DbExpression found = Find(expression.Input.Expression);
                if(!object.ReferenceEquals(found, expression.Input.Expression))
                {
                    return found.BindAs(expression.Input.VariableName).Sort(expression.SortOrder);
                }
                else
                {
                    return expression;
                }
            }

19. Example

View license
public override DbExpression Visit(DbSkipExpression expression)
            {
                DbExpression found = Find(expression.Input.Expression);
                if (!object.ReferenceEquals(found, expression.Input.Expression))
                {
                    return found.BindAs(expression.Input.VariableName).Skip(expression.SortOrder, expression.Count);
                }
                else
                {
                    return expression;
                }
            }

20. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpressionBinding ProcessAliasedFromClauseItem(AST.AliasedExpr aliasedExpr, Semanti/n ..... /n //View Source file for more details /n }

21. Example

View license
public override DbExpression Visit(DbSkipExpression e)
        {
            //Build the right input of the except
            DbExpression rightInput = VisitExpressionBinding(e.Input).Sort(VisitSortOrder(e.SortOrder)).Limit(VisitExpression(e.Count));

            //Build the left input for the except
            DbExpression leftInput = VisitExpression(e.Input.Expression); //Another copy of the input

            IList<DbSortClause> sortOrder = VisitSortOrder(e.SortOrder); //Another copy of the sort order
            
            // Create a list of the sort expressions to be used for translating except
            IList<DbPropertyExpression> sortExpressions = new List<DbPropertyExpression>(e.SortOrder.Count);
            foreach (DbSortClause sortClause in sortOrder)
            {
                //We only care about property expressions, not about constants
                if (sortClause.Expression.ExpressionKind == DbExpressionKind.Property)
                {
                    sortExpressions.Add((DbPropertyExpression)sortClause.Expression);
                }
            }

            DbExpression exceptExpression = TransformIntersectOrExcept(leftInput, rightInput, DbExpressionKind.Skip, sortExpressions, e.Input.VariableName);

            DbExpression result = exceptExpression.BindAs(e.Input.VariableName).Sort(sortOrder);  

            return result;
        }

22. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpressionBinding ProcessWhereHavingClausePredicate(DbExpressionBinding source, AST/n ..... /n //View Source file for more details /n }

23. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpression ConvertQueryStatementToDbExpression(AST.Statement astStatement, Semantic/n ..... /n //View Source file for more details /n }

24. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpressionBinding ProcessFromClause(AST.FromClause fromClause, SemanticResolver sr)/n ..... /n //View Source file for more details /n }

25. Example

View license
internal static DbExpression TranslateContains(ExpressionConverter parent, Expression sourceExpressi/n ..... /n //View Source file for more details /n }

26. Example

View license
internal override CqtExpression Translate(ExpressionConverter parent, MethodCallExpression call, Seq/n ..... /n //View Source file for more details /n }

27. Example

Project: referencesource
Source File: OrderByLifter.cs
View license
internal virtual DbExpression OfType(TypeUsage type)
                {
                    // s.OfType<T> is normally translated to s.Filter(e => e is T).Project(e => e as T)
                    DbExpressionBinding rootBinding = _root.BindAs(_aliasGenerator.Next());
                    DbExpression filter = this.Filter(rootBinding.Filter(rootBinding.Variable.IsOf(type)));
                    OrderByLifterBase filterLifter = GetLifter(filter, _aliasGenerator);
                    DbExpressionBinding filterBinding = filter.BindAs(_aliasGenerator.Next());
                    DbExpression project = filterLifter.Project(filterBinding.Project(filterBinding.Variable.TreatAs(type)));
                    return project;
                }

28. Example

View license
private DbExpression GenerateStructuralTypeResultMappingView(DbExpression storeFunctionInvoke, IList/n ..... /n //View Source file for more details /n }

29. Example

View license
internal override DbExpression Translate(ExpressionConverter parent, MethodCallExpression call)
    /n ..... /n //View Source file for more details /n }

30. Example

View license
private DbExpression RewriteCollection(DbExpression expression, CollectionType collectionType)
     /n ..... /n //View Source file for more details /n }

31. Example

Project: referencesource
Source File: ObjectContext.cs
View license
private int BatchRefreshEntitiesByKey(RefreshMode refreshMode, Dictionary<EntityKey, EntityEntry&/n ..... /n //View Source file for more details /n }

32. Example

Project: referencesource
Source File: ITreeGenerator.cs
View license
private DbExpression ApplyIsOfFilter(DbExpression current, IsOfFilter typeFilter)
        {
        /n ..... /n //View Source file for more details /n }

33. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpressionBinding ProcessOrderByClause(DbExpressionBinding source, AST.QueryExpr qu/n ..... /n //View Source file for more details /n }

34. Example

Project: referencesource
Source File: ViewSimplifier.cs
View license
private static DbExpression SimplifyNestedTphDiscriminator(DbExpression expression)
        {
      /n ..... /n //View Source file for more details /n }

35. Example

Project: referencesource
Source File: SemanticAnalyzer.cs
View license
private static DbExpressionBinding ProcessGroupByClause(DbExpressionBinding source, AST.QueryExpr qu/n ..... /n //View Source file for more details /n }

36. Example

View license
internal override CqtExpression Translate(ExpressionConverter parent, MethodCallExpression call)
   /n ..... /n //View Source file for more details /n }

37. 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 }