incorrect use of GetMulti() ?

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 08-Nov-2005 14:29:46   

Hi, I have in my application a databound grid showing my audited events (being of type HistoryCollection). Sometimes i want to force an update of the grid-display, and then i use the GetMulti method and rebind the collection.

I use the following (shortened) code to achieve this:


            HistoryCollection hcoll = null;

            if (m_currentEntity is ContractEntity)
            {
                hcoll= (m_currentEntity as ContractEntity).GetMultiHistory(true);
            }
            if (m_currentEntity is ReceptionEntity)
            {
                hcoll= (m_currentEntity as ReceptionEntity).GetMultiHistory(true);
            }
            //..other types possible, cut for clarity

            //sort by date entered
            hcoll.SupportsSorting = true;
            hcoll.Sort("HistDateEntered",ListSortDirection.Ascending,Comparer.Default);
            gridHistoriek.DataSource = hcoll;

I always found this code somewhat slow to perform, and when i enable "break into debugger" for all CLR execptions (Ctrl+Alt+E in visual studio, or Debug->Exceptions menu) i encounter a break with the exception


A first chance exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll

Additional information: Index was outside the bounds of the array.

with the following stack-trace:


>   agro.datalayer.dll!Agro.Datalayer.DaoClasses.HistoryDAO.CreateAndRunMultiInstanceRetrievalQuery( SD.LLBLGen.Pro.ORMSupportClasses.IEntityFields fieldsToReturn = {SD.LLBLGen.Pro.ORMSupportClasses.EntityFields}, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection collectionToFill = {Agro.Datalayer.CollectionClasses.HistoryCollection}, long maxNumberOfItemsToReturn = 0, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IEntityFactory entityFactoryToUse = {Agro.Datalayer.FactoryClasses.HistoryEntityFactory}, SD.LLBLGen.Pro.ORMSupportClasses.IPredicate selectFilter = {SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression}, SD.LLBLGen.Pro.ORMSupportClasses.IValidator validatorToUse = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relations = <undefined value>, int pageNumber = 0, int pageSize = 0) Line 565    C#
    agro.datalayer.dll!Agro.Datalayer.DaoClasses.HistoryDAO.GetMulti( SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection collectionToFill = {Agro.Datalayer.CollectionClasses.HistoryCollection}, long maxNumberOfItemsToReturn = 0, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IEntityFactory entityFactoryToUse = {Agro.Datalayer.FactoryClasses.HistoryEntityFactory}, SD.LLBLGen.Pro.ORMSupportClasses.IValidator validatorToUse = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression filter = <undefined value>, Agro.Datalayer.EntityClasses.ContractEntityBase contractInstance = <undefined value>, Agro.Datalayer.EntityClasses.PerceelEntityBase perceelInstance = <undefined value>, Agro.Datalayer.EntityClasses.ReceptionEntityBase receptionInstance = {Agro.Datalayer.EntityClasses.ReceptionEntity}, Agro.Datalayer.EntityClasses.SeasonEntityBase seasonInstance = <undefined value>, Agro.Datalayer.EntityClasses.SupplierEntityBase supplierInstance = <undefined value>, Agro.Datalayer.EntityClasses.UserEntityBase userInstance = <undefined value>, int pageNumber = 0, int pageSize = 0) Line 228    C#
    agro.datalayer.dll!Agro.Datalayer.CollectionClasses.HistoryCollection.GetMultiManyToOne( Agro.Datalayer.EntityClasses.ContractEntityBase contractInstance = <undefined value>, Agro.Datalayer.EntityClasses.PerceelEntityBase perceelInstance = <undefined value>, Agro.Datalayer.EntityClasses.ReceptionEntityBase receptionInstance = {Agro.Datalayer.EntityClasses.ReceptionEntity}, Agro.Datalayer.EntityClasses.SeasonEntityBase seasonInstance = <undefined value>, Agro.Datalayer.EntityClasses.SupplierEntityBase supplierInstance = <undefined value>, Agro.Datalayer.EntityClasses.UserEntityBase userInstance = <undefined value>, long maxNumberOfItemsToReturn = 0, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression filter = <undefined value>, int pageNumber = 0, int pageSize = 0) Line 190 + 0x74 bytes    C#
    agro.datalayer.dll!Agro.Datalayer.CollectionClasses.HistoryCollection.GetMultiManyToOne( Agro.Datalayer.EntityClasses.ContractEntityBase contractInstance = <undefined value>, Agro.Datalayer.EntityClasses.PerceelEntityBase perceelInstance = <undefined value>, Agro.Datalayer.EntityClasses.ReceptionEntityBase receptionInstance = {Agro.Datalayer.EntityClasses.ReceptionEntity}, Agro.Datalayer.EntityClasses.SeasonEntityBase seasonInstance = <undefined value>, Agro.Datalayer.EntityClasses.SupplierEntityBase supplierInstance = <undefined value>, Agro.Datalayer.EntityClasses.UserEntityBase userInstance = <undefined value>, SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression filter = <undefined value>) Line 127 + 0x64 bytes   C#
    agro.datalayer.dll!Agro.Datalayer.EntityClasses.ReceptionEntityBase.GetMultiHistory(bool forceFetch = true, SD.LLBLGen.Pro.ORMSupportClasses.IEntityFactory entityFactoryToUse = {Agro.Datalayer.FactoryClasses.HistoryEntityFactory}, SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression filter = <undefined value>) Line 1215  C#
    agro.datalayer.dll!Agro.Datalayer.EntityClasses.ReceptionEntityBase.GetMultiHistory(bool forceFetch = true) Line 1162 + 0x23 bytes  C#
    agro.detailforms.dll!Agro.Detailforms.HistoryControl.DoBinding() Line 223 + 0x1f bytes  C#


I know it's only a first-chance exception, and afterwards my list is correctly displayed in the grid, but it's taking an unusual long time for only a few records to fetch. Am i using the GetMulti incorrectly ? I use the mechanism of binding the grid to subobject-collections in numerous places and i never get that exception. But then again i never used explicitly "GetMulti" before this ..

btw still using the 2004 version of llblgen.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Nov-2005 15:06:33   

Please check the HistoryDAO.CreateAndRunMultiInstanceRetrievalQuery routine (it's in the generated code, at the bottom), and please check which object apparently causes the index violation. It's a strange error though...

Frans Bouma | Lead developer LLBLGen Pro
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 08-Nov-2005 23:35:46   

it happens when executing the line


base.ExecuteMultiRowRetrievalQuery(selectQuery, containingTransaction, entityFactoryToUse, collectionToFill, false, validatorToUse);

but i cannot step into this code ...

selectQuery looks ok at this point, containingtransaction = null, validatorToUse = null, collectionToFill is a collection with count = 0, and EntityFactoryToUse looks also ok at first sight.

Remember, if i don't set the "break into debugger" on CLR exceptions the code gives no error. It's just that it was a tad slow, so i started investigating why that was, and setting the debugger to break on exceptions is always a good start for investigation smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Nov-2005 09:56:02   

HcD wrote:

it happens when executing the line


base.ExecuteMultiRowRetrievalQuery(selectQuery, containingTransaction, entityFactoryToUse, collectionToFill, false, validatorToUse);

but i cannot step into this code ...

Weird, the stacktrace you posted shows it happens in the method calling that method... (CreateAndRun... )

selectQuery looks ok at this point, containingtransaction = null, validatorToUse = null, collectionToFill is a collection with count = 0, and EntityFactoryToUse looks also ok at first sight.

Hmm. And which version are you using? (build nr) Does it occur only with this fetch or with all fetches?

Frans Bouma | Lead developer LLBLGen Pro
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 10-Nov-2005 16:10:10   

i'm still using using LLBLGen build 1.0.2004.2 Final 26/may/2005 RuntimeLibraries_10082005.zip Templates_10122005.zip .NET 1.1 SP1 and would rather not upgrade to another version for another month (project finish date)

i have it only here, but it's also the first time i use "GetMulti"...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 10-Nov-2005 17:02:28   

Runtime libs of 1.0.2004.2 after may 26th can be used with code generated with templates released on may 26th, so you can try the last builds of 1.0.2004.2, without a problem. See if that makes a difference.

Frans Bouma | Lead developer LLBLGen Pro
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 10-Nov-2005 17:07:49   

Hmm i was under the impression that RuntimeLibraries_10082005.zip Templates_10122005.zip actually were the lastest libraries for usage with 1.0.2004.2 ?

I meant i would rather not upgrade to the 1.0.2005.1 ...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 11-Nov-2005 11:46:00   

HcD wrote:

Hmm i was under the impression that RuntimeLibraries_10082005.zip Templates_10122005.zip actually were the lastest libraries for usage with 1.0.2004.2 ? I meant i would rather not upgrade to the 1.0.2005.1 ...

My mistake, I read 'runtime libs may 26th', but that was the designer flushed .

1008 is the last version indeed. I uploaded a fix for 1.0.2004.2 yesterday but that's a fix for oracle schema overwriting which failed, not related to your problem.

Frans Bouma | Lead developer LLBLGen Pro