Constructor
let query = new EntityQuery("Customers")
Usually this constructor will be followed by calls to filtering, ordering or selection methods
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.orderBy("Region");
either a resource name or a serialized EntityQuery ( created by EntityQuery.toJSON)
The DataService for this query. Read Only
The EntityManager for this query. This may be null and can be set via the 'using' method.
The [[ExpandClause]] used by this query. Read Only
The EntityType that is associated with the 'from' clause ( resourceName) of the query. This is only guaranteed to be be set AFTER the query has been executed because it depends on the MetadataStore associated with the EntityManager that the query was executed against. This value may be null if the entityType cannot be associated with a resourceName. Read Only
Whether an inline count is returned for this query. Read Only
Whether entity tracking has been disabled for this query. Read Only
The OrderByClause used by this query. Read Only
Any additional parameters that were added to the query via the 'withParameters' method. Read Only
The QueryOptions for this query. Read Only
The resource name used by this query. Read Only
The entityType that will be returned by this query. This property will only be set if the 'toType' method was called. Read Only
The [[SelectClause]] used by this query. Read Only
The number of entities to 'skip' for this query. Read Only
The number of entities to 'take' for this query. Read Only
The 'where' Predicate used by this query. Read Only
Executes this query. This method requires that an EntityManager has been previously specified via the "using" method.
This method can be called using a 'promises' syntax ( recommended)
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders").using(em);
query.execute().then( function(data) {
... query results processed here
}).catch( function(err) {
... query failure processed here
});
or with callbacks
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders").using(em);
query.execute(
function(data) {
let orders = data.results;
... query results processed here
},
function(err) {
... query failure processed here
});
Either way this method is the same as calling the EntityManager 'execute' method.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders");
em.executeQuery(query).then( function(data) {
let orders = data.results;
... query results processed here
}).catch( function(err) {
... query failure processed here
});
Function called on success.
Function called on failure.
Promise
Executes this query against the local cache. This method requires that an EntityManager have been previously specified via the "using" method.
// assume em is an entityManager already filled with order entities;
let query = new EntityQuery("Orders").using(em);
let orders = query.executeLocally();
Note that calling this method is the same as calling EntityManager.executeQueryLocally.
Returns a new query that will return related entities nested within its results. The expand method allows you to identify related entities, via navigation property names such that a graph of entities may be retrieved with a single request. Any filtering occurs before the results are 'expanded'.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.expand("Orders");
will return the filtered customers each with its "Orders" properties fully resolved. Multiple paths may be specified by separating the paths by a ','
let query = new EntityQuery("Orders")
.expand("Customer, Employee")
and nested property paths my be specified as well
let query = new EntityQuery("Orders")
.expand("Customer, OrderDetails, OrderDetails.Product")
A comma-separated list of navigation property names or an array of navigation property names. Each Navigation Property name can be followed by a '.' and another navigation property name to enable identifying a multi-level relationship. If 'propertyPaths' is either null or omitted then any existing 'expand' clause on the query is removed.
Specifies the resource to query for this EntityQuery.
let query = new EntityQuery()
.from("Customers");
is the same as
let query = new EntityQuery("Customers");
The resource to query.
Returns a query with the 'inlineCount' capability either enabled or disabled. With 'inlineCount' enabled, an additional 'inlineCount' property will be returned with the query results that will contain the number of entities that would have been returned by this query with only the 'where'/'filter' clauses applied, i.e. without any 'skip'/'take' operators applied. For local queries this clause is ignored.
let query = new EntityQuery("Customers")
.take(20)
.orderBy("CompanyName")
.inlineCount(true);
will return the first 20 customers as well as a count of all of the customers in the remote store.
(default = true) Whether or not inlineCount capability should be enabled. If this parameter is omitted, true is assumed.
Returns a query with the 'noTracking' capability either enabled or disabled. With 'noTracking' enabled, the results of this query will not be coerced into entities but will instead look like raw javascript projections. i.e. simple javascript objects.
let query = new EntityQuery("Customers")
.take(20)
.orderBy("CompanyName")
.noTracking(true);
(default = true) Whether or not the noTracking capability should be enabled. If this parameter is omitted, true is assumed.
Returns a new query that orders the results of the query by property name. By default sorting occurs is ascending order, but sorting in descending order is supported as well. OrderBy clauses may be chained.
let query = new EntityQuery("Customers")
.orderBy("CompanyName");
or to sort across multiple properties
let query = new EntityQuery("Customers")
.orderBy("Region, CompanyName");
Nested property paths are also supported
let query = new EntityQuery("Products")
.orderBy("Category.CategoryName");
Sorting in descending order is supported via the addition of ' desc' to the end of any property path.
let query = new EntityQuery("Customers")
.orderBy("CompanyName desc");
or
let query = new EntityQuery("Customers")
.orderBy("Region desc, CompanyName desc");
A comma-separated (',') string of property paths or an array of property paths. Each property path can optionally end with " desc" to force a descending sort order. If 'propertyPaths' is either null or omitted then all ordering is removed.
If specified, overrides all of the embedded 'desc' tags in the previously specified property paths.
Returns a new query that orders the results of the query by property name. By default sorting occurs is ascending order, but sorting in descending order is supported as well. OrderBy clauses may be chained.
let query = new EntityQuery("Customers")
.orderBy("CompanyName");
or to sort across multiple properties
let query = new EntityQuery("Customers")
.orderBy("Region, CompanyName");
Nested property paths are also supported
let query = new EntityQuery("Products")
.orderBy("Category.CategoryName");
Sorting in descending order is supported via the addition of ' desc' to the end of any property path.
let query = new EntityQuery("Customers")
.orderBy("CompanyName desc");
or
let query = new EntityQuery("Customers")
.orderBy("Region desc, CompanyName desc");
Returns a new query that orders the results of the query by property name in descending order.
let query = new EntityQuery("Customers")
.orderByDesc("CompanyName");
or to sort across multiple properties
let query = new EntityQuery("Customers")
.orderByDesc("Region, CompanyName");
Nested property paths are also supported
let query = new EntityQuery("Products")
.orderByDesc("Category.CategoryName");
A comma-separated (',') string of property paths or an array of property paths. If 'propertyPaths' is either null or omitted then all ordering is removed.
Returns a new query that orders the results of the query by property name in descending order.
let query = new EntityQuery("Customers")
.orderByDesc("CompanyName");
or to sort across multiple properties
let query = new EntityQuery("Customers")
.orderByDesc("Region, CompanyName");
Nested property paths are also supported
let query = new EntityQuery("Products")
.orderByDesc("Category.CategoryName");
Returns a new query that selects a list of properties from the results of the original query and returns the values of just these properties. This will be referred to as a projection. If the result of this selection "projection" contains entities, these entities will automatically be added to EntityManager's cache and will be made 'observable'. Any simple properties, i.e. strings, numbers or dates within a projection will not be cached are will NOT be made 'observable'.
Simple data properties can be projected
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.select("CompanyName");
This will return an array of objects each with a single "CompanyName" property of type string. A similar query could return a navigation property instead
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.select("Orders");
where the result would be an array of objects each with a single "Orders" property that would itself be an array of "Order" entities. Composite projections are also possible:
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.select("CompanyName, Orders");
As well as projections involving nested property paths
let query = EntityQuery("Orders")
.where("Customer.CompanyName", "startsWith", "C")
.select("Customer.CompanyName, Customer, OrderDate");
A comma-separated (',') string of property paths or an array of property paths. If 'propertyPaths' is either null or omitted then any existing projection on the query is removed.
Returns a new query that skips the specified number of entities when returning results. Any existing 'skip' can be cleared by calling 'skip' with no arguments.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C")
.skip(5);
The number of entities to skip over. If omitted or null any existing skip count on the query is removed.
Returns a new query that returns only the specified number of entities when returning results - Same as 'top'. Any existing take can be cleared by calling take with no arguments.
let query = new EntityQuery("Customers")
.take(5);
The number of entities to return. If 'count' is either null or omitted then any existing 'take' count on the query is removed.
Specifies the top level EntityType that this query will return. Only needed when a query returns a json result that does not include type information.
let query = new EntityQuery()
.from("MyCustomMethod")
.toType("Customer")
The top level EntityType that this query will return. This method is only needed when a query returns a json result that does not include type information. If the json result consists of more than a simple entity or array of entities, consider using a JsonResultsAdapter instead.
Returns a new query that returns only the specified number of entities when returning results. - Same as 'take'. Any existing 'top' can be cleared by calling 'top' with no arguments.
let query = new EntityQuery("Customers")
.top(5);
The number of entities to return. If 'count' is either null or omitted then any existing 'top' count on the query is removed.
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
The object to update in creating a new EntityQuery from an existing one.
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
Returns a copy of this EntityQuery with the specified EntityManager, DataService, JsonResultsAdapter, MergeStrategy or FetchStrategy applied.
// 'using' can be used to return a new query with a specified EntityManager.
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(em);
or with a specified MergeStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(MergeStrategy.PreserveChanges);
or with a specified FetchStrategy
let em = new EntityManager(serviceName);
let query = new EntityQuery("Orders")
.using(FetchStrategy.FromLocalCache);
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Can be either
a single Predicate
the parameters to create a 'simple' Predicate
a null or undefined ( this causes any existing where clause to be removed)
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query with an added filter criteria; Can be called multiple times which means to 'and' with any existing Predicate or can be called with null to clear all predicates.
let query = new EntityQuery("Customers")
.where("CompanyName", "startsWith", "C");
This can also be expressed using an explicit FilterQueryOp as
let query = new EntityQuery("Customers")
.where("CompanyName", FilterQueryOp.StartsWith, "C");
or a preconstructed Predicate may be used
let pred = new Predicate("CompanyName", FilterQueryOp.StartsWith, "C");
let query = new EntityQuery("Customers").where(pred);
Predicates are often useful when you want to combine multiple conditions in a single filter, such as
let pred = Predicate.create("CompanyName", "startswith", "C").and("Region", FilterQueryOp.Equals, null);
let query = new EntityQuery("Customers")
.where(pred);
More complicated queries can make use of nested property paths
let query = new EntityQuery("Products")
.where("Category.CategoryName", "startswith", "S");
or OData functions - A list of valid OData functions can be found within the Predicate documentation.
let query = new EntityQuery("Customers")
.where("toLower(CompanyName)", "startsWith", "c");
or to be even more baroque
let query = new EntityQuery("Customers")
.where("toUpper(substring(CompanyName, 1, 2))", FilterQueryOp.Equals, "OM");
Returns a new query that includes a collection of parameters to pass to the server.
let query = EntityQuery.from("EmployeesFilteredByCountryAndBirthdate")
.withParameters({ BirthDate: "1/1/1960", Country: "USA" });
will call the 'EmployeesFilteredByCountryAndBirthdate' method on the server and pass in 2 parameters. This query will be uri encoded as
{serviceApi}/EmployeesFilteredByCountryAndBirthdate?birthDate=1%2F1%2F1960&country=USA
Parameters may also be mixed in with other query criteria.
let query = EntityQuery.from("EmployeesFilteredByCountryAndBirthdate")
.withParameters({ BirthDate: "1/1/1960", Country: "USA" })
.where("LastName", "startsWith", "S")
.orderBy("BirthDate");
A parameters object where the keys are the parameter names and the values are the parameter values.
This is a static version of the "from" method and it creates a 'base' entityQuery for the specified resource name.
let query = EntityQuery.from("Customers");
is the same as
let query = new EntityQuery("Customers");
The resource to query.
Static method that creates an EntityQuery that will allow 'requerying' an entity or a collection of entities by primary key. This can be useful to force a requery of selected entities, or to restrict an existing collection of entities according to some filter.
Works for a single entity or an array of entities of the SAME type. Does not work for an array of entities of different types.
// assuming 'customers' is an array of 'Customer' entities retrieved earlier.
let customersQuery = EntityQuery.fromEntities(customers);
The resulting query can, of course, be extended
// assuming 'customers' is an array of 'Customer' entities retrieved earlier.
let customersQuery = EntityQuery.fromEntities(customers)
.where("Region", FilterQueryOp.NotEquals, null);
Single entities can requeried as well.
// assuming 'customer' is a 'Customer' entity retrieved earlier.
let customerQuery = EntityQuery.fromEntities(customer);
will create a query that will return an array containing a single customer entity.
Static method that creates an EntityQuery that will allow 'requerying' an entity or a collection of entities by primary key. This can be useful to force a requery of selected entities, or to restrict an existing collection of entities according to some filter.
Works for a single entity or an array of entities of the SAME type. Does not work for an array of entities of different types.
// assuming 'customers' is an array of 'Customer' entities retrieved earlier.
let customersQuery = EntityQuery.fromEntities(customers);
The resulting query can, of course, be extended
// assuming 'customers' is an array of 'Customer' entities retrieved earlier.
let customersQuery = EntityQuery.fromEntities(customers)
.where("Region", FilterQueryOp.NotEquals, null);
Single entities can requeried as well.
// assuming 'customer' is a 'Customer' entity retrieved earlier.
let customerQuery = EntityQuery.fromEntities(customer);
will create a query that will return an array containing a single customer entity.
Creates an EntityQuery for the specified EntityKey.
let empType = metadataStore.getEntityType("Employee");
let entityKey = new EntityKey(empType, 1);
let query = EntityQuery.fromEntityKey(entityKey);
or
// 'employee' is a previously queried employee
let entityKey = employee.entityAspect.getKey();
let query = EntityQuery.fromEntityKey(entityKey);
Creates an EntityQuery for the specified entity and NavigationProperty.
// 'employee' is a previously queried employee
let ordersNavProp = employee.entityType.getProperty("Orders");
let query = EntityQuery.fromEntityNavigation(employee, ordersNavProp);
will return a query for the "Orders" of the specified 'employee'.
The Entity whose navigation property will be queried.
The NavigationProperty or name of the NavigationProperty to be queried.
Generated using TypeDoc
An EntityQuery instance is used to query entities either from a remote datasource or from a local EntityManager.
EntityQueries are immutable - this means that all EntityQuery methods that return an EntityQuery actually create a new EntityQuery. This means that EntityQueries can be 'modified' without affecting any current instances.