New Posts New Posts RSS Feed: UsingAGridBuilder
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

UsingAGridBuilder

 Post Reply Post Reply
Author
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Topic: UsingAGridBuilder
    Posted: 27-May-2010 at 12:26am
I converted this application to vs 2010 and devforce 2010
 
Now i have an error wen accessing an navigational property for ex. Product.Supplier
 
{"Index was outside the bounds of the array."}
 
I have this problem with all my apps i ported to vs 2010
 
Where does this come from ?
 
StackTrace :
 
   at IdeaBlade.EntityModel.EntityQueryBuilder.<>c__DisplayClass7.<BuildMultiEqualExpr>b__6(MemberExpression expr, Int32 i)
   at System.Linq.Enumerable.<SelectIterator>d__7`2.MoveNext()
   at IdeaBlade.EntityModel.EntityQueryBuilder.And(IEnumerable`1 expressions)
   at IdeaBlade.EntityModel.EntityQueryBuilder.BuildMultiEqualExpr(IEnumerable`1 propExpressions, Object[] values)
   at IdeaBlade.EntityModel.EntityQueryBuilder.<>c__DisplayClass4.<BuildLambdaKeyQuery>b__3(EntityKey key)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at IdeaBlade.EntityModel.EntityQueryBuilder.Or(IEnumerable`1 expressions)
   at IdeaBlade.EntityModel.EntityQueryBuilder.BuildLambdaKeyQuery(IEnumerable`1 keys)
   at IdeaBlade.EntityModel.EntityQueryBuilder.BuildQuery(IEnumerable`1 keys)
   at IdeaBlade.EntityModel.EntityKeyFinder.Execute()
   at IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean isAsync)
   at IdeaBlade.EntityModel.EntityManager.FirstOrNullEntity(IEntityQuery query)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.QueryForEntity(EntityReferenceStrategy strategy)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.GetEntity(EntityReferenceStrategy strategy)
   at IdeaBlade.EntityModel.NavigationScalarEntityProperty`2.<.ctor>b__0(NavigationEntityPropertyGetInterceptorArgs`2 args)
   at IdeaBlade.Core.PropertyInterceptor`3.HandleAction(Action`1 action, TArgs args)
   at IdeaBlade.Core.PropertyInterceptor`3.<BuildTargetedCombinedAction>b__3(TArgs args)
   at IdeaBlade.Core.PropertyInterceptor`3.ExecuteActions(TArgs args)
   at IdeaBlade.Core.PropertyInterceptor`3.GetValue(TInstance instance, Object context)
   at IdeaBlade.EntityModel.NavigationScalarEntityProperty`2.GetValue(TInstance instance)
   at ServerModelNorthwindIB.Employee.get_Manager() in C:\Users\Public\Documents\DevForce 2010\Learning Resources\200WNF_GridBuilder\CodeCS\ServerModelNorthwindIB\ServerModelNorthwindIB.IB.Designer.cs:line 713
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 27-May-2010 at 8:09pm
Hi Sky - The application you sent over is too large for us to tell what is going on.  You'll need to simplify the the solution - perhaps to just those two related objects so that we can take a look.
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2010 at 1:52am
this is my loaddata
private BindableList<Employee> _employees = new BindableList<Employee>();
var query = _em.BasePersons
                .Include(Employee.PathFor(sa => sa.CommissionCode))
                .Include(Employee.PathFor(sa => sa.SalesInvoiceAgents))
                .Include(Employee.PathFor(sa => sa.Address))
                .Include(Employee.PathFor(sa => sa.Address.Country))  <-- the moment i include this it fails
                 .OfType<Employee>();
_employees.ReplaceRange(query.ToList());
 
I made sure every employee had an address and each address has a country assigned to it
 
Then I create my grid and bind the data
 
GridControl employeeGridControl;
 XtraGridBindingManager bindingManager;
_GridBuilder2.CreateGrid(out employeeGridControl, out bindingManager,  _employeeBS, typeof(Employee));
 
_GridBuilder2.AddColumn(bindingManager, Employee.PathFor(e => e.Name));
_GridBuilder2.AddColumn(bindingManager, Employee.PathFor(e => e.CommissionCode.AlfaCode));
_GridBuilder2.AddColumn(bindingManager, Employee.PathFor(e => e.NumberOfUnpaidInvoices));
_GridBuilder2.AddColumn(bindingManager, Employee.PathFor(e => e.Address.City));
_GridBuilder2.AddColumn(bindingManager, Employee.PathFor(e => e.Address.Country.NameNld));
 
I had the same problem before with other data and then I could resolve the problem by adding an include in the loaddata of the extra data needed
 
 
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2010 at 7:30pm
Hi Sky,
 
We just saw a similar issue from another customer.  You can get the "Index was outside the bounds of the array" error if the foreign key references are missing from the EDMX.  I went back and looked at the solution you submitted and noticed that most of the foreign key references were not present, including the SupplierID on the Product entity.
 
Did you try to convert this from a .NET 3.5 Entity Framework model (not a good idea) or did you build it from scratch using the Entity Framework in .NET 4.0?
 
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 27-Jul-2010 at 7:02am
I now made a complete new EDMX was a hell of a job, and i made some improvements.
 
Now I only seem to have the problem when the entity is inherited.
 
Employee.Commissioncode.Procent
 
where Commissioncode is inherited from a Basecode (TPH).
 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down