SqlDataSource.Relations Property
Provides access to the collection of master-detail relations of the SqlDataSource.
Namespace: DevExpress.DataAccess.Sql
Assembly: DevExpress.DataAccess.v24.2.dll
Declaration
[LocalizableCategory(DataAccessStringId.PropertyGridDataCategoryName)]
public MasterDetailInfoCollection Relations { get; }
Property Value
Type | Description |
---|---|
MasterDetailInfoCollection | A MasterDetailInfoCollection object. |
Remarks
To add a relationship between two tables, add a MasterDetailInfo instance to the SqlDataSource.Relations
collection:
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.ConnectionParameters;
// ...
void AddQueryRelations()
{
SelectQuery categories = SelectQueryFluentBuilder
.AddTable("Categories")
.SelectAllColumns()
.Build("Categories");
SelectQuery products = SelectQueryFluentBuilder
.AddTable("Products")
.SelectAllColumns()
.Build("Products");
DataSource.Queries.AddRange(new SqlQuery[] { categories, products });
DataSource.Relations.Add(
new MasterDetailInfo("Categories", "Products", "CategoryID", "CategoryID"));
}
For more information, review the following help topic: Manage Table Relations.
The full code is available in the sample application:
See Also