Click or drag to resize

OrmQueryResultSetTResultWhere(ExpressionFuncTResult, Boolean) Method

Filter the result set where the specified condition matches

Namespace: SanteDB.OrmLite
Assembly: SanteDB.OrmLite (in SanteDB.OrmLite.dll) Version: 3.0.2081-alpha+d0a78774d3f97b9193d2ae2fef6d129ea9f29519
Syntax
public IQueryResultSet<TResult> Where(
	Expression<Func<TResult, bool>> query
)

Parameters

query  ExpressionFuncTResult, Boolean
The query to apply

Return Value

IQueryResultSetTResult
The filtered result collection

Implements

IQueryResultSetTDataWhere(ExpressionFuncTData, Boolean)
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