Example of how represent data returned by LINQ in hierarchical form by using Master-Details

Hello Syncfusion's team,

Can you provide me an example that :

1) Uses LINQ to retrieve two lists of data from a data source (SQL Server) : for example list of customers (Master) and list of orders (sub table = details).

2) Represents the two previouse lists in hierarchical form by using Master-Details.

Thanks you in advance


Best regards

Cosyspro


7 Replies

DD Dhivyabharathi Dakshinamurthy Syncfusion Team January 29, 2024 06:59 PM UTC

Hi Cosyspro,

Currently we are analyzing the reported scenario, we need time to validate and will provide an update on or before January 31, 2024.

 

Regards,

DhivyaBharathi Dakshinamurthy



DD Dhivyabharathi Dakshinamurthy Syncfusion Team January 31, 2024 06:09 PM UTC

Hi Cosyspro,


Query 1 : We can retrieve the data source from SQL using LINQ. Kindly refer the following link.

How To Use LINQ To SQL For Retrieving Data From SQL Server Database (c-sharpcorner.com)


In Query 2 : SfDataGrid provides support for representing data in a hierarchical form through the Master-Details view. Kindly refer to the following link:

Master Details View in WinForms DataGrid control | Syncfusion

 

Regards,

DhivyaBharathi Dakshinamurthy



CO Cosyspro February 1, 2024 02:18 PM UTC

Hi  DhivyaBharathi Dakshinamurthy,

Thank you for your response.

I think my previous message was not clear.

My problem is how to represent the list of data, that have been returned by LINQ request, in hierarchical form through the Master-Details view without using DataTable ?

Thank you

Cosyspro

Regards



DD Dhivyabharathi Dakshinamurthy Syncfusion Team February 2, 2024 06:14 PM UTC

Hi Cosyspro,

Currently we are analyzing the reported scenario, we need time to validate and will provide an update on or before February 06, 2024.

 

Regards,

DhivyaBharathi Dakshinamurthy



DD Dhivyabharathi Dakshinamurthy Syncfusion Team February 6, 2024 05:38 PM UTC

Hi Cosyspro,

  • When retrieving data from the database using a LINQ query, it is often assumed that the data should be in DataTable format. However, there are alternative methods for obtaining data without using DataTables.

  • Could you please confirm which type of collection is used?

  • Also, could you please explain what kind of collection you use and how you get the data from the database?

  • If possible, please share a simple sample of how data is returned using a LINQ query.

 

Regards,

DhivyaBharathi Dakshinamurthy



CO Cosyspro replied to Dhivyabharathi Dakshinamurthy February 7, 2024 06:47 PM UTC

Hi  DhivyaBharathi Dakshinamurthy ,

The LINQ query returns an IEnumerable result from SQL Server.

Regards.

Cosyspro



DD Dhivyabharathi Dakshinamurthy Syncfusion Team February 9, 2024 03:29 PM UTC

Hi Cosyspro,

The relation of Master-Details view can be generated for the properties of type IEnumerable in the underlying data object.

Here in this sample, we created the OrderInfo Class, this will contain the details for Master, this class contains the property called OrderDetails, OrderDetails holds the data for child (sub-Table).

Create the data source with relations (Here, relations are IEnumerable type properties).
OrderDetails will be the RealtionalColumn here.

To define the Master-Details view relations, create GridViewDefinition and set the name of IEnumerable type property (from data object) to GridViewDefinition.RelationalColumn. Then, add the GridViewDefinition to the SfDataGrid.DetailsViewDefinitions.


You can use this as reference to create a Master-Details view from the data returned from the LINQ.

Regards,
DhivyaBharathi Dakshinamurthy


Attachment: MasterDetailsView_Demo_6460ef9a.zip

Loader.
Up arrow icon