Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

XPQuery<T>.WithDeleted() Method

Creates an XPQuery<T> based on the current XPQuery<T> instance. The new query retrieves objects specified by the original query and also selects objects marked as deleted that match that query.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public XPQuery<T> WithDeleted()

Returns

Type Description
XPQuery<T>

An XPQuery<T> instance.

Remarks

The following example demonstrates how to employ the WithDeleted method in an application:

unitOfWork.Query<Employee>()
    .WithDeleted()
    .Where(e => e.Name == null).ToList();

new XPQuery<Employee>(unitOfWork)
     .WithDeleted()
     .Where(e => e.Name == null).ToList();

To use the WithDeleted feature, make sure to initialize the XPQuery<T> with the XPQuery(Session) or XPQuery(Session, Boolean) constructor.

If you use a constructor that does not take the Session argument, the XPQuery<T> cannot get objects marked for deletion and the following error is displayed: “The WithDeleted option is not supported because XPQuery was initialized with DataLayer. To use the WithDeleted option, employ the XPQuery(Session) or XPQuery(Session, Boolean) constructor.

See Also