Back to Devexpress

SelectQuery.GroupFilterString Property

corelibraries-devexpress-dot-dataaccess-dot-sql-dot-selectquery-ba9903dc.md

latest3.3 KB
Original Source

SelectQuery.GroupFilterString Property

Specifies the filter criteria to add to the current SelectQuery containing grouped/aggregated columns.

Namespace : DevExpress.DataAccess.Sql

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
[DefaultValue(null)]
[LocalizableCategory(DataAccessStringId.QueryPropertyGridTableSelectionCategoryName)]
public string GroupFilterString { get; set; }
vb
<DefaultValue(Nothing)>
<LocalizableCategory(DataAccessStringId.QueryPropertyGridTableSelectionCategoryName)>
Public Property GroupFilterString As String

Property Value

TypeDefaultDescription
Stringnull

A String value.

|

Remarks

The GroupFilterString property allows you to filter the result set returned by SelectQuery if it contains grouped/aggregated columns. For example, the following query will return only categories that contain a specific number of products.

csharp
//...
SelectQuery selectQuery1 = new SelectQuery("MyQuery")
    .AddTable("Products")
    .SelectColumn("ProductID", AggregationType.Count, "ProductsCount")
    .SelectColumn("CategoryID")
    .GroupBy("CategoryID");

selectQuery1.GroupFilterString = "[ProductsCount] > 5";
vb
'...

Dim selectQuery1 As SelectQuery = New SelectQuery("MyQuery") _ 
    .AddTable("Products") _ 
    .SelectColumn("ProductID", AggregationType.Count, "ProductsCount") _ 
    .SelectColumn("CategoryID") _ 
    .GroupBy("CategoryID")

selectQuery1.GroupFilterString = "[ProductsCount] > 5"

To pass a QueryParameter (which can be accessed using the SqlQuery.Parameters property) to the filter string, precede the parameter name with the ? sign.

csharp
//...
QueryParameter queryParam1 = new QueryParameter("Parameter1", typeof(Int32), 200);
selectQuery1.Parameters.Add(queryParam1);

selectQuery1.GroupFilterString = "[TotalStock] > ?Parameter1";
vb
'...
Dim queryParam1 As New QueryParameter("Parameter1", GetType(Int32), 200)
selectQuery1.Parameters.Add(queryParam1)

selectQuery1.GroupFilterString = "[TotalStock] > ?Parameter1"

See Also

Groups

FilterString

SelectQuery Class

SelectQuery Members

DevExpress.DataAccess.Sql Namespace