Hello,
I have an Entity, Company, that has a property exposing a list of child entities, Car.
For a quick run I created an instance of my Entity:
Company company = new Company() { Name = "Ford", City = "Detroit" };
and then initialized the child entity collection and added two children:
company.Car = new System.Data.Objects.DataClasses.EntityCollection<Car>();
company.Car.Add( new Car() { Name = "Mustang" } );
company.Car.Add( new Car() { Name = "Explorer" } );
I manually defined the schema with my first Band with a Key of, "Company", and the child band to a Key of, "Car".
The parent record is visible, but the child is not. How should I be doing this?
Thank you,
Blu
If you don't see the "+" sign beside each row, yu need to write:
grid.DisplayLayout.ViewStyle = ViewStyle.MultiBand
I think you also shouldn't always construct a new collection for Car. When you make a new Company you can start adding Cars without constructing its collection first. If you want to make sure there is nothing in the collection then use Clear(). This is very important when you bind the collection. If you construct a new collection you might lose the binding.
I commented out: company.Car = new System.Data.Objects.DataClasses.EntityCollection<Car>();
I changed the view style in Grid_InitializeLayout and it did not add the + symbol for the child rows.
private void Grid_InitializeLayout( ...
{
...
e.Layout.ViewStyle = ViewStyle.MultiBand;
}
It appears to me that the EntityCollection doesn't support any of the required interfaces that would mark it as a child list by the DotNet BindingManager.
In order for this to work, the list of cars must implement IList or IBindingList.
It does implement IListSource, which is interesting. This seems to imply that the EntityCollection contains multiple lists. This makes it unsuitable to display as a set of child bands, but theoretically, you could bind the grid directly to the Cars collection, then, as long as you specified a DataMember as well as a DataSource.
From MSDN:
"An EntityCollection<(Of <(TEntity>)>) is a collection of objects of a particular entity type that represents the "many" end of a one-to-many or many-to-many relationship."
I tried to set the data memeber to "Cars", but a binding exceptions was thrown.
Is there a quick example of binding the UltraWinGrid to entities from the EntityFramework, I only see dataset based examples in the, "Dig into Code" section? I can start there and see if the Grid will work for our applications.
Thanks for the reply.
I'm afraid I know of no samples using the EntityFramework. I'm not really familiar with this framework. But from what you have posted here, it does not appear to be designed for data binding - at least not in a hierarchical situation.
Hi Mike, It appears the last mention of entity framework and infragistics was almost 2 years ago. Has there been any samples released regarding the binding of EF4 and infragistics controls, are there any plans to do so?
Hi,
There aren't any samples of this that I know of.
I'm afraid I don't know of any plans to create some. I recommend that you Submit a feature request to Infragistics.