Okay, Iv'e been battling this for a couple of hours and can not get it to work correctly. I have the following code:
Public Shared Function GetAllSubjectAreas() As EntityCollection
Dim Sorter As ISortExpression = New SortExpression
Sorter.Add(SortClauseFactory.Create(Elementary.GradeBook.LLBL.SubjectAreaFieldIndex.SortKey, SortOperator.Ascending))
Dim Sorter2 As ISortExpression = New SortExpression
Sorter2.Add(SortClauseFactory.Create(SubSkillFieldIndex.SortKey, SortOperator.Ascending))
GetAllSubjectAreas = New EntityCollection(New SubjectAreaEntityFactory)
Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.SubjectAreaEntity, Integer))
PrefetchPath.Add(SubjectAreaEntity.PrefetchPathSubSkill, Nothing, Nothing, Nothing, Sorter2)
_Adapter.FetchEntityCollection(GetAllSubjectAreas, Nothing, Nothing, Sorter, PrefetchPath)
Return GetAllSubjectAreas
End Function
It is suppose to fetch all SubjectArea and associated SubSkill records sorted by SortKey.
I get the following error when I run the code:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32& uniqueMarker)
at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at MedfordSchoolDistrict.Elementary.GradeBook.LLBL.DatabaseSpecific.DataAccessAdapter.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in C:\SISnet Project\ElementaryGradeBookLLBL\DatabaseSpecific\DataAccessAdapter.vb:line 521
This is the code in DataAccessAdapter that aborts
Protected Overloads Overrides Function CreateSelectDQ(fieldsToFetch As IEntityFields2, persistenceInfoObjects As IFieldPersistenceInfo(), _
filter As IPredicateExpression, maxNumberOfItemsToReturn As Long, sortClauses As ISortExpression, relationsToWalk As IRelationCollection, _
allowDuplicates As Boolean, groupByClause As IGroupByCollection, pageNumber As Integer, pageSize As Integer) As IRetrievalQuery
Return DynamicQueryEngine.CreateSelectDQ(fieldsToFetch.GetAsEntityFieldCoreArray(), _
persistenceInfoObjects, MyBase.GetActiveConnection(), filter, maxNumberOfItemsToReturn, sortClauses, relationsToWalk, allowDuplicates, groupByClause, pageNumber, pageSize)
End Function
The first Select on SubjectArea seems to go correctly. The second select is when it aborts. The predicate on the second select contains zero parameters, which does not seem right.
Any help would be greatly appriciated.
Fishy
btw, why is it when I paste my code in the forum it's left justified and when I paste your code it leaves the correct indented spacing?