Skip to main content
.NET 6.0+

IObjectSpace.CreateDataView(Type, IList<DataViewExpression>, CriteriaOperator, IList<SortProperty>) Method

Returns a list of data records retrieved from a database without loading complete business classes (a data view).

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

IList CreateDataView(
    Type objectType,
    IList<DataViewExpression> expressions,
    CriteriaOperator criteria,
    IList<SortProperty> sorting
)

Parameters

Name Type Description
objectType Type

The Type of requested objects.

expressions IList<DataViewExpression>

An IList<DataViewExpression> list that specifies data view column names and expressions used to compute column values. These column names can be used for sorting data view via the sorting parameter.

criteria CriteriaOperator

A CriteriaOperator object that specifies criteria associated with the data view.

sorting IList<SortProperty>

An IList<SortProperty> collection whose elements identify the sorted columns within the data view.

Returns

Type Description
IList

An IList object that returns a lightweight list of data records.

Remarks

This method does not return real objects. Instead, a lightweight read-only list of data records that can be viewed much more quickly than a real objects collection is returned.

This method result can be directly cast to XafDataView.

List<DataViewExpression> dataViewExpressions = new List<DataViewExpression>();
dataViewExpressions.Add(
    new DataViewExpression("ID", new OperandProperty("ID")));
dataViewExpressions.Add(new DataViewExpression(
    "Name.UpperCase", new FunctionOperator(FunctionOperatorType.Upper, new OperandProperty("Name"))));
dataViewExpressions.Add(new DataViewExpression(
    "Count", new AggregateOperand("Sales", Aggregate.Count)));
CriteriaOperator criteria = new BinaryOperator(
    "Sales.Count", 0, BinaryOperatorType.Greater);
SortProperty[] sorting = new SortProperty[] { 
    new SortProperty("Name", SortingDirection.Ascending)
};
XafDataView dataView = (XafDataView)objectSpace.CreateDataView(
    typeof(Sale), dataViewExpressions, criteria, sorting);
See Also