Print Page | Close Window

OrderBy: Ideablade should throw an exception

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1104
Printed Date: 28-Jul-2025 at 9:14pm


Topic: OrderBy: Ideablade should throw an exception
Posted By: Dominique
Subject: OrderBy: Ideablade should throw an exception
Date Posted: 27-Feb-2009 at 9:11am
Hi

I upgrade to the latest DF version (from 3.5.something to 3.6.x)  and started migrating a project in a new code tree as a maintenance task.
After I was finished to fix the references that had been changed and get my app to compile I was getting a weird error when starting the app, getting this exception

System.IndexOutOfRangeException was unhandled by user code
  Message="Index was outside the bounds of the array."
  Source="System.Data"
  StackTrace:
   at System.Data.Select.CreateIndex()   
at System.Data.Select.SelectRows()  
 at System.Data.DataTable.Select(String filterExpression, String sort)   
at IdeaBlade.Persistence.EntityQuery.FindRows(PersistenceManager pPersistenceManager)   
at IdeaBlade.Persistence.PersistenceManager.QueryEntityFinder.FindRows()   
at IdeaBlade.Persistence.PersistenceManager.MergeAndReturnUsingCache(IEntityFinder pEntityFinder, DataSet pFetchedDataSet, FixupCacheAndUpdateResultsCallback pFixupCallback, WorkState pWorkState)   
at IdeaBlade.Persistence.PersistenceManager.ProcessFetchedDataSet(DataSet pFetchedDataSet, WorkState pWorkState)   
at IdeaBlade.Persistence.PersistenceManager.XFetch(IEntityFinder pEntityFinder, WorkState pWorkState)   
at IdeaBlade.Persistence.PersistenceManager.XFetch(IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy, WorkState pWorkState)   
at IdeaBlade.Persistence.PersistenceManager.XGetEntities(IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy, WorkState pWorkState)   
at IdeaBlade.Persistence.PersistenceManager.GetEntities[T](IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy)
   at IdeaBlade.Persistence.PersistenceManager.GetEntities[T](IEntityQuery pEntityQuery)
     [cut out calls in my app]

Because I load the data in the background it took me some time to find the source of the problem because the exception message was not very helpful.
The problem was that I had the same order clause added twice to a spanQuery I think that the ideablade framework should check for that and give a good exception as it will result to an error in the core dotnet.
code snippet that illustrated the faulty code
         aSpanQuery.AddSpan(EntityRelations.Order_OrderLines)

        aSpanQuery.AddOrderBy(Order.ShipDateEntityColumn, System.ComponentModel.ListSortDirection.Descending) -- (a)
        aSpanQuery.AddOrderBy(Order.ShipDateEntityColumn, System.ComponentModel.ListSortDirection.Descending) ' OOPS same as (a)

        Dim tmp As EntityList(Of Order) = mPersistMng.GetEntities(Of Order)(aSpanQuery) 'KABOUM!





-------------
Dominique



Replies:
Posted By: GregD
Date Posted: 27-Feb-2009 at 10:10am
Originally posted by Dominique


The problem was that I had the same order clause added twice to a spanQuery I think that the ideablade framework should check for that and give a good exception as it will result to an error in the core dotnet.

code snippet that illustrated the faulty code
        aSpanQuery.AddSpan(EntityRelations.Order_OrderLines)
        aSpanQuery.AddOrderBy(Order.ShipDateEntityColumn, System.ComponentModel.ListSortDirection.Descending) -- (a)
        aSpanQuery.AddOrderBy(Order.ShipDateEntityColumn, System.ComponentModel.ListSortDirection.Descending) ' OOPS same as (a)

        Dim tmp As EntityList(Of Order) = mPersistMng.GetEntities(Of Order)(aSpanQuery) 'KABOUM!


Thanks for the heads up, Dominique: I've entered this as a bug. We'll see if we can get you a better error message.

Regards
Greg Dunn
IdeaBlade




Print Page | Close Window