Back to Devexpress

EntityServerModeDataSource.Selecting Event

aspnet-devexpress-dot-data-dot-linq-dot-entityservermodedatasource.md

latest3.1 KB
Original Source

EntityServerModeDataSource.Selecting Event

Enables you to provide a custom data source.

Namespace : DevExpress.Data.Linq

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event EventHandler<LinqServerModeDataSourceSelectEventArgs> Selecting
vb
Public Event Selecting As EventHandler(Of LinqServerModeDataSourceSelectEventArgs)

Event Data

The Selecting event's data class is LinqServerModeDataSourceSelectEventArgs. The following properties provide information specific to this event:

PropertyDescription
DefaultSortingSpecifies how data source contents are sorted by default, when sort order is not specified by the bound control.
KeyExpressionGets or sets the key expression.
QueryableSourceGets or sets the queryable data source.

Remarks

The Selecting event is raised before data is retrieved from a data source, and allows you to provide a custom data source. The custom data source is specified by the LinqServerModeDataSourceSelectEventArgs.QueryableSource property. In this instance, you should also specify the name of the key property using the LinqServerModeDataSourceSelectEventArgs.KeyExpression property.

Example

The following example illustrates how to use the Selecting event.

csharp
protected void EntityServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) {
    var db = new YourDataContext();
    e.KeyExpression = "ID_FIELD_FROM_YOUR_TABLE";
    e.QueryableSource = db.Products;
    //or
    e.QueryableSource = db.Products.Where(p=>p.Price > 10);
    //or other linq query
}
vb
Protected Sub EntityServerModeDataSource1_Selecting(ByVal sender As Object, ByVal e As DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs)
    Dim db = New YourDataContext()
    e.KeyExpression = "ID_FIELD_FROM_YOUR_TABLE"
    e.QueryableSource = db.Products
    e.QueryableSource = db.Products.Where(Function(p) p.Price > 10)
End Sub

See Also

EntityServerModeDataSource Class

EntityServerModeDataSource Members

DevExpress.Data.Linq Namespace