Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Binding to LINQ to SQL Classes

Follow the steps below to bind your data-aware control to data using the LINQ to SQL provider.

Expanded Prerequisites

Latest Visual Studio versions (for example, Visual Studio 2017) do not have required modules installed by default. For these versions, you have to install required tools manually. To do so, open Windows Start Menu and run "Visual Studio Installer".

Select "Modify" for the required Visual Studio installation, switch to "Individual components" tab and check the "LINQ to SQL tools" option.

Click the "Modify" button to start the installation. After the IDE is updated, close the Installer.

Expanded Binding to LINQ to SQL Classes

  1. Open the Visual Studio Server Browser and right-click "Data Connections" to add a new connection.

  2. Invoke a Data Source Configuration Wizard and select the "LINQ to SQL" option.

  3. Click "New Data Source..." button and add a new "LINQ to SQL Classes" item to your project.

    If LINQ to SQL tools are not installed, this button is hidden. To do so, install these tools manually as shown in the Prerequisites section.

  4. Data classes are created and edited in an Object Relational Designer (O/R Designer). To create a data class, drag it from the Server Explorer onto the O/R Designer's surface.

  5. Rebuild the project and close the O/R Designer.

  6. Invoke a Data Source Configuration Wizard once again and select the "LINQ to SQL" option. This time the data source you have created is listed among available data sources. Select it and click "Next".

  7. Choose the required data binding mode.

    • Direct Binding to Data Source - the data-aware control binds directly to the data source, without any go-between components.

    • Binding via the BindingSource Component - a new System.Windows.Forms.BindingSource component is created to transfer data to your data-aware control.

    • Asynchronous Server-Side Data Processing - the LinqInstantFeedbackSource component transfers data. The data-aware control operates in Instant Feedback Mode.

    • Server-Side Data Processing - the LinqServerModeSource component transfers data. The data-aware control operates in regular Server Mode.

    • Asynchronous Parallel In-Memory Data Processing - the PLinqInstantFeedbackSource component transfers data. The data-aware control operates in Instant Feedback Mode.

    • Parallel In-Memory Data Processing - the PLinqServerModeSource component transfers data. The data-aware control operates in regular Server Mode.

  8. The final wizard page allows you to sort your data descending or ascending by a selected data field.

  9. Click "Finish" and rebuild the solution. Your data-aware control is now bound to LINQ-to-SQL classes.

Expanded Posting Data Back to the Data Source

Call the SubmitChanges method to save changes back to a data-aware control's underlying data source.

How would you rate this topic?​​​​​​​