Click or drag to resize

IQueryResultSetTDataWhere(ExpressionFuncTData, Boolean) Method

Filter the result set where the specified condition matches

Namespace: SanteDB.Core.Model.Query
Assembly: SanteDB.Core.Model (in SanteDB.Core.Model.dll) Version: 3.0.2081-alpha+0a330d5f5a5d3cb3e6e945ef530e94ac5671b49c
Syntax
IQueryResultSet<TData> Where(
	Expression<Func<TData, bool>> query
)

Parameters

query  ExpressionFuncTData, Boolean
The query to apply

Return Value

IQueryResultSetTData
The filtered result collection
Exceptions
ExceptionCondition
InvalidOperationExceptionWhen a WHERE clause has already been appended
Remarks

This instruction appends a SQL WHERE clause to your query. This can only be called once on a particular instance of a IQueryResultSetTData or else an invalid state is created. When calling directly from a persistence layer such as:

var results = persistenceService.Query(o => o.StatusConceptKey == StatusKeys.Active, AuthenticationContext.Current.Princiapl); var filter = results.Where(o=> o.CreationTime > DateTime.Now); // invalid state

The method is intended for new result sets, for example, consider:

var results = persistenceService.Query(o => o.StatusConceptKey == StatusKeys.Active, AuthenticationContext.Current.Princiapl); results = results.Union(o => o.StatusConceptKey.New); var filter = results.Where(o=> o.CreationTime > DateTime.Now);

Since the equivalent function in SQL is:

SELECT * FROM ( SELECT * FROM x WHERE sts_cd_id = 'ACTIVE_UUID' UNION SELECT * FROM x WHERE sts_cd_id = 'NEW_UUID' ) I WHERE I.crt_utc > CURRENT_TIMESTAMP
See Also