本文整理汇总了C#中DbFilterExpression类的典型用法代码示例。如果您正苦于以下问题:C# DbFilterExpression类的具体用法?C# DbFilterExpression怎么用?C# DbFilterExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbFilterExpression类属于命名空间,在下文中一共展示了DbFilterExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public override SqlFragment Visit(DbFilterExpression expression)
{
SelectStatement select = VisitInputExpressionEnsureSelect(expression.Input.Expression,
expression.Input.VariableName, expression.Input.VariableType);
select = WrapIfNotCompatible(select, expression.ExpressionKind);
select.Where = expression.Predicate.Accept(this);
return select;
}
示例2: Visit
public override Expression Visit(DbFilterExpression 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 predicate = this.Visit(expression.Predicate);
LambdaExpression predicateLambda = Expression.Lambda(predicate, param);
return queryMethodExpressionBuilder.Where(source, predicateLambda);
}
}
示例3: Visit
/// <summary>
/// This method called before the one below it when a filtering is already exists in the query (e.g. fetch an entity by id)
/// so we apply the dynamic filtering at this level
/// </summary>
public override DbExpression Visit(DbFilterExpression expression)
{
var column = TenantAwareAttribute.GetTenantColumnName(expression.Input.Variable.ResultType.EdmType);
if (!_injectedDynamicFilter && !string.IsNullOrEmpty(column))
{
var newFilterExpression = BuildFilterExpression(expression.Input, expression.Predicate, column);
if (newFilterExpression != null)
{
// If not null, a new DbFilterExpression has been created with our dynamic filters.
return base.Visit(newFilterExpression);
}
}
return base.Visit(expression);
}
示例4: Visit
public override DbExpression Visit(DbFilterExpression expression)
{
// If the query contains it's own filter condition (in a .Where() for example), this will be called
// before Visit(DbScanExpression). And it will contain the Predicate specified in that filter.
// Need to inject our dynamic filters here and then 'and' the Predicate. This is necessary so that
// the expressions are properly ()'d.
// It also allows us to attach our dynamic filter into the same DbExpressionBinding so it will avoid
// creating a new sub-query in MS SQL Server.
string entityName = expression.Input.Variable.ResultType.EdmType.Name;
var containers = _ObjectContext.MetadataWorkspace.GetItems<EntityContainer>(DataSpace.SSpace).First();
var filterList = FindFiltersForEntitySet(expression.Input.Variable.ResultType.EdmType.MetadataProperties, containers);
var newFilterExpression = BuildFilterExpressionWithDynamicFilters(entityName, filterList, expression.Input, expression.Predicate);
if (newFilterExpression != null)
{
// If not null, a new DbFilterExpression has been created with our dynamic filters.
return newFilterExpression;
}
return base.Visit(expression);
}
示例5: Visit
public override DbExpression Visit(DbFilterExpression expression)
{
// If the query contains it's own filter condition (in a .Where() for example), this will be called
// before Visit(DbScanExpression). And it will contain the Predicate specified in that filter.
// Need to inject our dynamic filters here and then 'and' the Predicate. This is necessary so that
// the expressions are properly ()'d.
// It also allows us to attach our dynamic filter into the same DbExpressionBinding so it will avoid
// creating a new sub-query in MS SQL Server.
string entityName = expression.Input.Variable.ResultType.EdmType.Name;
var filterList = expression.Input.Variable.ResultType.EdmType.MetadataProperties
.Where(mp => mp.Name.Contains("customannotation:" + DynamicFilterConstants.AttributeNamePrefix))
.Select(m => m.Value as DynamicFilterDefinition);
var newFilterExpression = BuildFilterExpressionWithDynamicFilters(entityName, filterList, expression.Input, expression.Predicate);
if (newFilterExpression != null)
{
// If not null, a new DbFilterExpression has been created with our dynamic filters.
return newFilterExpression;
}
return base.Visit(expression);
}
示例6: Visit
// For Distinct, Limit, OfType there is no need to override the base visitor behavior.
public override DbExpression Visit(DbFilterExpression expression)
{
Check.NotNull(expression, "expression");
// Only consider the Filter input
var found = Find(expression.Input.Expression);
if (!ReferenceEquals(found, expression.Input.Expression))
{
return found.BindAs(expression.Input.VariableName).Filter(expression.Predicate);
}
else
{
return expression;
}
}
示例7: Visit
public override void Visit(DbFilterExpression e)
{
VisitExprKind(e.ExpressionKind);
_key.Append('(');
VisitBinding(e.Input);
_key.Append('(');
e.Predicate.Accept(this);
_key.Append("))");
}
示例8: Filter
internal override DbExpression Filter(DbFilterExpression filter)
{
return filter;
}
示例9: Visit
public override void Visit(DbFilterExpression e)
{
Begin(e);
Dump(e.Input, "Input");
Dump(e.Predicate, "Predicate");
End(e);
}
示例10: Visit
public override void Visit(DbFilterExpression expression) { }
示例11: Visit
public override DbExpression Visit(DbFilterExpression expression)
{
System.Diagnostics.Debug.Print("Visit(DbFilterExpression): {0}", expression);
return base.Visit(expression);
}
示例12: Visit
/// <summary>
/// Visitor pattern method for <see cref="DbFilterExpression" />.
/// </summary>
/// <param name="expression"> The DbFilterExpression that is being visited. </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression" />
/// is null
/// </exception>
public override void Visit(DbFilterExpression expression)
{
Check.NotNull(expression, "expression");
VisitExpressionBindingPre(expression.Input);
VisitExpression(expression.Predicate);
VisitExpressionBindingPost(expression.Input);
}
示例13: Visit
/// <summary>
/// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbFilterExpression"/>.
/// </summary>
/// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.DbFilterExpression"/> that is visited.</param>
public override void Visit(DbFilterExpression expression)
{
if (expression == null)
{
throw new ArgumentNullException("expression");
}
expression.Input.Expression.Accept(this);
expression.Predicate.Accept(this);
}
示例14: Visit
public override void Visit(DbFilterExpression expression)
{
Contract.Requires(expression != null);
}
示例15: Visit
// For Distinct, Limit, OfType there is no need to override the base visitor behavior.
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;
}
}