Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Predicate<T>

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.

Type parameters

  • T

Hierarchy

  • Predicate

Index

Constructors

Properties

Methods

Constructors

constructor

  • Predicate constructor

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

    or

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

    Parameters

    • Rest ...args: any[]

    Returns Predicate

Properties

op

op: Op

visitorMethodName

visitorMethodName: string

Methods

and

  • and(...args: any[]): AndOrPredicate
  • 'And's this Predicate with one or more other Predicates and returns a new 'composite' Predicate

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

    or

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

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

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

    Parameters

    • Rest ...args: any[]

    Returns AndOrPredicate

not

  • not(): UnaryPredicate
  • Returns the 'negated' version of this Predicate

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

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

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

    which would be the same as

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

    Returns UnaryPredicate

or

  • or(...args: any[]): AndOrPredicate
  • 'Or's this Predicate with one or more other Predicates and returns a new 'composite' Predicate

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

    or

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

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

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

    Parameters

    • Rest ...args: any[]

    Returns AndOrPredicate

toJSON

  • toJSON(): any

toString

  • toString(): string

Static and

  • and(...args: any[]): AndOrPredicate
  • Creates a 'composite' Predicate by 'and'ing a set of specified Predicates together.

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

    or

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

    Parameters

    • Rest ...args: any[]

    Returns AndOrPredicate

Static create

  • create(...args: any[]): Predicate
  • Same as using the ctor.

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

    Parameters

    • Rest ...args: any[]

    Returns Predicate

Static not

  • not(pred: Predicate): UnaryPredicate
  • Creates a 'composite' Predicate by 'negating' a specified predicate.

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

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

     let not_p1 = p1.not();
    

    Both of which would be the same as

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

    Parameters

    • pred: Predicate

    Returns UnaryPredicate

Static or

  • or(...args: any[]): AndOrPredicate
  • Creates a 'composite' Predicate by 'or'ing a set of specified Predicates together.

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

    or

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

    Parameters

    • Rest ...args: any[]

    Returns AndOrPredicate

Generated using TypeDoc