Show:

Predicate Class

Defined in: a44_predicate.js:4
Module: breeze

Used to define a 'where' predicate for an EntityQuery. Predicates are immutable, which means that any method that would modify a Predicate actually returns a new Predicate.

Item Index

Methods

Methods

<ctor> Predicate

(
  • property
  • operator
  • value
)

Defined in a44_predicate.js:10

Predicate constructor

Parameters:

  • property String

    A property name, a nested property name or an expression involving a property name.

  • operator FilterQueryOp | String
  • value Object
    • This will be treated as either a property expression or a literal depending on context. In general, if the value can be interpreted as a property expression it will be, otherwise it will be treated as a literal. In most cases this works well, but you can also force the interpretation by making the value argument itself an object with a 'value' property and an 'isLiteral' property set to either true or false. Breeze also tries to infer the dataType of any literal based on context, if this fails you can force this inference by making the value argument an object with a 'value' property and a 'dataType' property set to one of the breeze.DataType enumeration instances.

Example:

var p1 = new Predicate("CompanyName", "StartsWith", "B");
var query = new EntityQuery("Customers").where(p1); 

or

var p2 = new Predicate("Region", FilterQueryOp.Equals, null);
var query = new EntityQuery("Customers").where(p2);

and

(
  • predicates
)
static

Defined in a44_predicate.js:86

Creates a 'composite' Predicate by 'and'ing a set of specified Predicates together.

Parameters:

  • predicates Multiple Predicates | Array of Predicate multiple

    Any null or undefined values passed in will be automatically filtered out before constructing the composite predicate.

Example:

var dt = new Date(88, 9, 12);
var p1 = Predicate.create("OrderDate", "ne", dt);
var p2 = Predicate.create("ShipCity", "startsWith", "C");
var p3 = Predicate.create("Freight", ">", 100);
var newPred = Predicate.and(p1, p2, p3);

or

var preds = [p1, p2, p3];
var newPred = Predicate.and(preds);

and

(
  • predicates
)

'And's this Predicate with one or more other Predicates and returns a new 'composite' Predicate

Parameters:

  • predicates Multiple Predicates | Array of Predicate multiple

    Any null or undefined values passed in will be automatically filtered out before constructing the composite predicate.

Example:

var dt = new Date(88, 9, 12);
var p1 = Predicate.create("OrderDate", "ne", dt);
var p2 = Predicate.create("ShipCity", "startsWith", "C");
var p3 = Predicate.create("Freight", ">", 100);
var newPred = p1.and(p2, p3);

or

var preds = [p2, p3];
var newPred = p1.and(preds);

The 'and' method is also used to write "fluent" expressions

var p4 = Predicate.create("ShipCity", "startswith", "F")
  .and("Size", "gt", 2000);

create

(
  • property
  • operator
  • value
)
static

Defined in a44_predicate.js:64

Same as using the ctor.

Parameters:

  • property String

    A property name, a nested property name or an expression involving a property name.

  • operator FilterQueryOp | String
  • value Object
    • This will be treated as either a property expression or a literal depending on context. In general, if the value can be interpreted as a property expression it will be, otherwise it will be treated as a literal. In most cases this works well, but you can also force the interpretation by making the value argument itself an object with a 'value' property and an 'isLiteral' property set to either true or false. Breeze also tries to infer the dataType of any literal based on context, if this fails you can force this inference by making the value argument an object with a 'value' property and a 'dataType' property set to one of the breeze.DataType enumeration instances.

Example:

// so 
var p = Predicate.create(a, b, c);
// is the same as 
var p = new Predicate(a, b, c); 

not

(
  • predicate
)
static

Creates a 'composite' Predicate by 'negating' a specified predicate.

Parameters:

Example:

var p1 = Predicate.create("Freight", "gt", 100);
var not_p1 = Predicate.not(p1);

This can also be accomplished using the 'instance' version of the 'not' method

var not_p1 = p1.not();

Both of which would be the same as

var not_p1 = Predicate.create("Freight", "le", 100);

not

()

Returns the 'negated' version of this Predicate

Example:

var p1 = Predicate.create("Freight", "gt", 100);
var not_p1 = p1.not();

This can also be accomplished using the 'static' version of the 'not' method

var p1 = Predicate.create("Freight", "gt", 100);
var not_p1 = Predicate.not(p1);

which would be the same as

var not_p1 = Predicate.create("Freight", "le", 100);

or

(
  • predicates
)
static

Creates a 'composite' Predicate by 'or'ing a set of specified Predicates together.

Parameters:

  • predicates Multiple Predicates | Array of Predicate multiple

    Any null or undefined values passed in will be automatically filtered out before constructing the composite predicate.

Example:

var dt = new Date(88, 9, 12);
var p1 = Predicate.create("OrderDate", "ne", dt);
var p2 = Predicate.create("ShipCity", "startsWith", "C");
var p3 = Predicate.create("Freight", ">", 100);
var newPred = Predicate.or(p1, p2, p3);

or

var preds = [p1, p2, p3];
var newPred = Predicate.or(preds);

or

(
  • predicates
)

'Or's this Predicate with one or more other Predicates and returns a new 'composite' Predicate

Parameters:

  • predicates Multiple Predicates | Array of Predicate multiple

    Any null or undefined values passed in will be automatically filtered out before constructing the composite predicate.

Example:

var dt = new Date(88, 9, 12);
var p1 = Predicate.create("OrderDate", "ne", dt);
var p2 = Predicate.create("ShipCity", "startsWith", "C");
var p3 = Predicate.create("Freight", ">", 100);
var newPred = p1.or(p2, p3);

or

var preds = [p2, p3];
var newPred = p1.or(preds);

The 'or' method is also used to write "fluent" expressions

var p4 = Predicate.create("ShipCity", "startswith", "F")
  .or("Size", "gt", 2000);