Have you got any real world example of how to use the WebHierarchicalDataSource, WebHierarchicalDataGrid and the Entity Framework to perform CRUD operations when using many to many and one to many relationships?
All the tutorials I have seen so far only use one table. This is not a real world example.
In the Northwind database we have the Orders, OrderDetails Products and categories tables. The OrderDetails table work as a mapping table even though it has more fields like UnitPrice, Quantity and Discount. So we have a many to many relationship Orders-OrderDetail-Products like this:
Orders---------> OrderDetails <--------Products<--------Categories.
1 - Can we use the Infragistic WebHierarchicalDataGrid and WebHierarchicalDataSource with the Entity Framework 4.0 so that we could create a grid and display all the related entities?
2 - Could we use CRUD operations on the grid? Would the WebHierarchicalDataGrid and WebHierarchicalDataSource know how to send the updates, insertions, deletes and using filters with the entity framework?
Example: The grid would display the following:
OrderID, OrderDate, Freight, ShipName, ShipCity (from Orders)UnitPrice, Quantity, Discount (from OrderDetails) ProductID, ProductName, CategoryName, Description (from Products and Categories)
3 - If I updated the CategoryName and save, will it be saved to the right Category table?
4 - What about to create a new record using all tables? what is the best way?
This is the kind of tutorial I think you should be creating to help people like me that use the Infragistic controls.
Could you please provide a sample code for the scenario described above?
Thank you for posting in our forum.
I’ll do my best to answer your questions in the order you’ve asked them as follows:
1) Yes. You can define a EntityDataSource control on the page and use that for the DataView that you’ll define for the WebHierarchicalDataSource. For example:
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NORTHWNDEntities1" DefaultContainerName="NORTHWNDEntities1" EntitySetName="Orders" EnableFlattening="False" ></asp:EntityDataSource>
In the WebHierarchicalDataSource you can define a view that will use that data source for example:
<ig:DataView ID="EntityDataSource1_DefaultView" DataMember="DefaultView" DataSourceID="EntityDataSource1" />
You can add as many entity data sources as the number of bands you want to have and define the relations between them.
For the grid you can define the bans and columns if you wish or you can leave the AutoGenerateBands and AutoGenerateColumns properties to be set to true. Then the grid will automatically generate the bands and columns based on the views and relations in the WebHierarchicalDataSource.
2) Yes. You can either use Auto CRUD which will automatically update the data source if the data source allows it. In this case if you set:
EnableDelete="True", EnableInsert="True" and EnableUpdate="True" for the entity data source it should handle the actions to the data source accordingly. To have the grid automatically update the data source you can set the AutoCRUD property of the EditingCore behavior to true.
If you’d rather handle the updating manually you can set it to false and handle the corresponding CRUD server side events: RowUpdating,RowAdding, RowDeleting. In them you’ll have the specific operation information and can manually update the data context.
3) Would the third level be based on some view which would be a join between the Products and Categories tables? By default it seems that there isn’t a joint view between them.
If that’s the case then that view would be update which in theory should update the underlying tables if the view allows it.
Also there are some restrictions when you update the data trough views: http://www.informit.com/articles/article.aspx?p=130855&seqNum=4
4) I’m not sure I understand what you mean by that. When adding a new row a single record is added to the corresponding to that band data member(table in the data source). Would you like to modify the record before it’s added to the data table based on some values in other tables?
I’ve attached a sample that uses the following hierarchy: Orders> Order_Details > Products for your reference with autoCRUD enabled. Due to the size limitation in the forum I’ve removed the Northwind data base from the App_Data folder . Adding it back on your side should allow you to run the sample.
Let me know if you have any questions or concerns.
Developer Support Engineer II
Many thanks for your reply. I will have a look at the sample code you provided and come back to you.
As I mentioned it would be great if you could produce real world video tutorials and examples of how to use the Infragistic controls with the Entity Framework and ASP Web API.
All the tutorials based on only one table are not very useful as you know.
Please can you work with your team to produce such tutorials. The reason why we purchase these controls is to help us develop enterprise applications faster and with less bugs.
However, if there is no real world video training of how to use the controls then it gets difficulty to make us of them.
I look forward to your reply.
Hello pallone ,
We appreciate that you took the time to convey your comments and I assure you that we consider our customer community comments very important to steering improvement at Infragistics.I’ve discussed this with our management team and they do plan on adding articles and blogs for using IG controls with Entity Framework in the future. For the moment however we don’t have accurate information on when exactly we’ll have these blogs and articles available.
If you have any specific questions or concerns don’t hesitate to let me know.
Hello pallone ,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Developer Support Engineer
I am working on something else at the moment and had to stop testing the contorls with the EF5. I really would like to see some real world video tutorials explaning how to use the controls to work with complex databases i.e. with lots of many to many one to many relationships.