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.