Navigation

Categories
Show Navigation Next Topic  »

IMPORTANT! Remember that only rules of evaluation type can be used in data filtering, where they are called filters.

Enumerable.Filter method

Declaring Class: CodeEffects.Rule.Core.RuleExtensions
Namespace: CodeEffects.Rule.Core

Provides rule-based data filtering capabilities to LINQ to Object queries. Uses the plain Evaluator class.

Example

IEnumerable result =
	arrayOfSourceObjects.Filter(typeof(SourceObject), ruleXml);

Returns

IEnumerable whose elements are filtered according to conditions set in the business rule.

Syntax

public static System.Collections.IEnumerable Filter(
	this System.Collections.IEnumerable source,
	Type type,
	string rulesetXml,
	string ruleId = null,
	GetRuleDelegate getRule = null)

Type Parameters

  • source, System.Collections.IEnumerable - A sequence of values of the source object's type to filter against the business rule.

Parameters

  • type, System.Type - Type of the source object that the rule was created with/for.
  • rulesetXml, System.String - This string can contain either a single Rule XML document, a single <rule> node that contains a rule, or a collection of rules called the ruleset.
  • ruleId, System.String - If the Rule XML passed in the previous parameter is a ruleset then this nullable parameter contains the ID of the particular rule located inside of that ruleset.
  • getRule, CodeEffects.Rule.Core.GetRuleDelegate - This nullable parameter takes a reference to a method that returns string Rule XML by rule ID. Pass this delegate if your rule may potentially reference reusable rules that are not stored in the same XML ruleset.

Enumerable.Filter<TSource> method

Declaring Class: CodeEffects.Rule.Core.RuleExtensions
Namespace: CodeEffects.Rule.Core

Provides XML rule-based data filtering capabilities to LINQ to Object queries, and uses the generic evaluator class.

Returns

IEnumerable<TSource> whose elements are filtered according to conditions set in the business rule.

Syntax

public static IEnumerable<TSource> Filter<TSource>(
	this IEnumerable<TSource> source,
	string rulesetXml,
	string ruleId = null,
	GetRuleDelegate getRule = null)

Type Parameters

  • source, System.Collections.IEnumerable<TSource> - A sequence of values of TSource type to filter against the business rule.

Parameters

  • rulesetXml, System.String - This string can contain either a single Rule XML document, a single <rule> node that contains a rule, or a collection of rules called the ruleset.
  • ruleId, System.String - If the Rule XML passed in the previous parameter is a ruleset then this nullable parameter contains the ID of the particular rule located inside of that ruleset.
  • getRule, CodeEffects.Rule.Core.GetRuleDelegate - This nullable parameter takes a reference to a method that returns string Rule XML by rule ID. Pass this delegate if your rule may potentially reference reusable rules that are not stored in the same XML ruleset.
Comments: 0
Post your questions about Code Effects on Stackoverflow and become a part of our growing community