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;
}
Setting the ViewStyle on the grid is unlikely to help, since MultiBand is the default. So this would only be a problem if you had already set this property to SingleBand.
What exactly is System.Data.Objects.DataClasses.EntityCollection? I couldn't find this type.I assume it implements IList<> or IBindingList<>, so that should be okay.
What is the grid's DataSource in this scenaria? Is is a single Company? Or a list of companies?
What does the Car property return before you set it to a new EntityCollection? Is it returning an empty list or is it null?
Are you binding the grid before or after adding the Cars?
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.
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?
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.
I'm using Linq to Sql and I don't have any problem with binding. I use EntitySet which also implements IList.
Is there a reason you're using Entity Framework? I think the only reason to prefer it and not Linq to Sql is the ability to seperate the data model and the conceptual model.
I'm working with Linq to Sql for a year now and it is much more simple, and I found a way to well integrate that with WCF.
I tried to do the same thing with Entity Framework and I went back to Linq to Sql after a month playing games with it.
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.