Skip to main content
A newer version of this page is available. .

LinqInstantFeedbackSource.DismissQueryable Event

Occurs when the LinqInstantFeedbackSource no longer needs the queryable source it used to retrieve objects from the data store.

Namespace: DevExpress.Data.Linq

Assembly: DevExpress.Data.v18.1.dll

Declaration

public event EventHandler<GetQueryableEventArgs> DismissQueryable

Event Data

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

Property Description
AreSourceRowsThreadSafe Specifies whether elements retrieved by the LinqInstantFeedbackSource‘s queryable source are thread-safe.
KeyExpression Gets or sets the name of the key property.
QueryableSource Gets or sets the queryable data source.
Tag Gets or sets an arbitrary object associated with a queryable source.

Remarks

You can access the object you have assigned to the GetQueryableEventArgs.Tag property in the LinqInstantFeedbackSource.GetQueryable event handler.

Example

This example demonstrates how to initialize a LinqInstantFeedbackSource, to retrieve data from a “Purchasing.PurchaseOrderHeader” data table (included in the AdventureWorks database shipped with MS SQL Server). The PurchaseOrderHeader persistent class is declared, and mapped to the “Purchasing.PurchaseOrderHeader” data table using the System.Data.Linq.Mapping.TableAttribute attribute. Then, a System.Data.Linq.Table<PurchaseOrderHeader> is passed to the LinqInstantFeedbackSource in the LinqInstantFeedbackSource.GetQueryable event handler.

using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using DevExpress.Data.Linq;

// The class describing the "Purchasing.PurchaseOrderHeader" table 
// from the AdventureWorks SQL database
[Table(Name="Purchasing.PurchaseOrderHeader")]
public partial class PurchaseOrderHeader : INotifyPropertyChanging, INotifyPropertyChanged {
    //...
    [Column(Storage="_PurchaseOrderID", AutoSync=AutoSync.OnInsert, 
        DbType="Int NOT NULL IDENTITY", 
        IsPrimaryKey=true, IsDbGenerated=true)]
    // The property mapped to the primary key column
    public int PurchaseOrderID {
    //...
    }
    //...
}

// The class describing the AdventureWorks SQL database
[DatabaseAttribute(Name="AdventureWorks")]
public partial class AdvWorksDataContext : DataContext {
    //...
    public System.Data.Linq.Table<PurchaseOrderHeader> PurchaseOrderHeaders {
        get {
            return this.GetTable<PurchaseOrderHeader>();
        }
    }
    //...
}

public partial class Form1 : Form {
    //...
    private void Form1_Load(object sender, EventArgs e) {
        // Specify the key property of the PurchaseOrderHeader
        linqInstantFeedbackSource1.KeyExpression = "PurchaseOrderID";
        // Handle the GetQueryable event, to create a DataContext and assign a queryable source
        linqInstantFeedbackSource1.GetQueryable += linqInstantFeedbackSource1_GetQueryable;
        // Handle the DismissQueryable event, to dispose of the DataContext
        linqInstantFeedbackSource1.DismissQueryable += linqInstantFeedbackSource1_DismissQueryable;
        // Assign the created data source to an XtraGrid
        gridControl1.DataSource = linqInstantFeedbackSource1;
    }
    void linqInstantFeedbackSource1_GetQueryable(object sender, GetQueryableEventArgs e) {
        // Instantiate a new DataContext
        AdvWorksDataContext dataContext = new AdvWorksDataContext();
        // Assign a queryable source to the LinqInstantFeedbackSource
        e.QueryableSource = dataContext.PurchaseOrderHeaders;
        // Assign the DataContext to the Tag property, 
        // to dispose of it in the DismissQueryable event handler
        e.Tag = dataContext;            
    }
    void linqInstantFeedbackSource1_DismissQueryable(object sender, GetQueryableEventArgs e) {
        // Dispose of the DataContext
        ((AdvWorksDataContext)e.Tag).Dispose();         
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DismissQueryable event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also