aspnet-devexpress-dot-data-dot-linq-dot-entityservermodedatasource.md
Enables you to provide a custom data source.
Namespace : DevExpress.Data.Linq
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event EventHandler<LinqServerModeDataSourceSelectEventArgs> Selecting
Public Event Selecting As EventHandler(Of LinqServerModeDataSourceSelectEventArgs)
The Selecting event's data class is LinqServerModeDataSourceSelectEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| DefaultSorting | Specifies how data source contents are sorted by default, when sort order is not specified by the bound control. |
| KeyExpression | Gets or sets the key expression. |
| QueryableSource | Gets or sets the queryable data source. |
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.
The following example illustrates how to use the Selecting event.
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
}
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