本文整理汇总了C#中DbProjectExpression类的典型用法代码示例。如果您正苦于以下问题:C# DbProjectExpression类的具体用法?C# DbProjectExpression怎么用?C# DbProjectExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbProjectExpression类属于命名空间,在下文中一共展示了DbProjectExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public override Expression Visit(DbProjectExpression expression)
{
Expression source = this.Visit(expression.Input.Expression);
Type elementType = TypeHelper.GetElementType(source.Type);
ParameterExpression param = Expression.Parameter(elementType, expression.Input.VariableName);
using (this.CreateVariable(param, expression.Input.VariableName))
{
Expression projection = this.Visit(expression.Projection);
LambdaExpression projectionLambda = Expression.Lambda(projection, param);
return queryMethodExpressionBuilder.Select(source, projectionLambda);
}
}
示例2: Project
internal override DbExpression Project(DbProjectExpression project)
{
// source.Sort(o).Limit(k).Project(p).Project(p2) -> source.Sort(o).Limit(k).Project(e => p2(p(e)))
return ComposeProject(
DbExpressionBuilder.Limit(_sort, _limit.Limit),
_project,
project);
}
示例3: Visit
/// <summary>
/// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbProjectExpression"/>.
/// </summary>
/// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.DbProjectExpression"/> that is visited.</param>
public override void Visit(DbProjectExpression expression)
{
if (expression == null)
{
throw new ArgumentNullException("expression");
}
expression.Projection.Accept(this);
expression.Input.Expression.Accept(this);
}
示例4: Visit
public override SqlFragment Visit(DbProjectExpression expression)
{
SelectStatement select = VisitInputExpressionEnsureSelect(expression.Input.Expression,
expression.Input.VariableName, expression.Input.VariableType);
// see if we need to wrap this select inside a new select
select = WrapIfNotCompatible(select, expression.ExpressionKind);
Debug.Assert(expression.Projection is DbNewInstanceExpression);
VisitNewInstanceExpression(select, expression.Projection as DbNewInstanceExpression);
return select;
}
示例5: Visit
public override void Visit(DbProjectExpression expression)
{
throw new NotSupportedException("Visit(\"ProjectExpression\") is not supported.");
}
示例6: Visit
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;
}
示例7: ProjectSortLifter
internal ProjectSortLifter(DbProjectExpression project, DbSortExpression sort, AliasGenerator aliasGenerator)
: base(project, aliasGenerator)
{
_project = project;
_sort = sort;
_source = sort.Input.Expression;
}
示例8: Visit
public override void Visit(DbProjectExpression expression) { }
示例9: ProjectLimitSortLifter
internal ProjectLimitSortLifter(
DbProjectExpression project, DbLimitExpression limit, DbSortExpression sort, AliasGenerator aliasGenerator)
: base(project, aliasGenerator)
{
_project = project;
_limit = limit;
_sort = sort;
}
示例10: Visit
public override DbExpression Visit(DbProjectExpression expression)
{
System.Diagnostics.Debug.Print("Visit(DbProjectExpression): {0}", expression);
return base.Visit(expression);
}
示例11: ComposeProject
protected static DbProjectExpression ComposeProject(
DbExpression input, DbProjectExpression first, DbProjectExpression second)
{
// source.Project(first).Project(second) -> source.Project(e => second(first(e)))
// create lambda expression representing the second projection (e => second(e))
var secondLambda = DbExpressionBuilder.Lambda(second.Projection, second.Input.Variable);
// invoke lambda with variable from the first projection
var composed = first.Input.Project(secondLambda.Invoke(first.Projection));
return RebindProject(input, composed);
}
示例12: Visit
/// <summary>
/// Visitor pattern method for <see cref="DbProjectExpression" />.
/// </summary>
/// <param name="expression"> The DbProjectExpression that is being visited. </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression" />
/// is null
/// </exception>
public override void Visit(DbProjectExpression expression)
{
Check.NotNull(expression, "expression");
VisitExpressionBindingPre(expression.Input);
VisitExpression(expression.Projection);
VisitExpressionBindingPost(expression.Input);
}
示例13: Visit
public override void Visit(DbProjectExpression e)
{
Check.NotNull(e, "e");
Begin(e);
Dump(e.Input, "Input");
Dump(e.Projection, "Projection");
End(e);
}
示例14: ProjectSkipLifter
internal ProjectSkipLifter(DbProjectExpression project, DbSkipExpression skip, AliasGenerator aliasGenerator)
: base(project, aliasGenerator)
{
_project = project;
_skip = skip;
_source = _skip.Input.Expression;
}
示例15: Visit
public override void Visit(DbProjectExpression e)
{
Begin(e);
Dump(e.Input, "Input");
Dump(e.Projection, "Projection");
End(e);
}