Hi all... I hope someone's awake that can help me with this... I've spent far too mcuh time trying to figure it out with not much to show...
Imagine the following table heirarchy:
Districts -> Schools -> Teachers -> Classes -> Lesson Plans -> Standards
I want all districts, schools, teachers, classes, lesson plans, and standards where the lesson plans have a specified range of standards. That part isn't the problem. The problem is, I only want to return the standards from the specified range instead of ALL standards associated to the lesson plans returned.
I'll try to copy/paste the related code below.
Dim districts As New EntityCollection(New DistrictEntityFactory())
Dim districtsPath As New PrefetchPath2(EntityType.DistrictEntity)
Dim schoolPath As SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPathElement2 = districtsPath.Add(DistrictEntity.PrefetchPathSchools)
Dim userPath As SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPathElement2 = schoolPath.SubPath.Add(SchoolEntity.PrefetchPathUsers)
Dim classPath As IPrefetchPathElement2 = userPath.SubPath.Add(UserEntity.PrefetchPathClasses)
Dim coursePath As PrefetchPathElement2 = classPath.SubPath.Add(ClassEntity.PrefetchPathCourse)
Dim gradePath As PrefetchPathElement2 = classPath.SubPath.Add(ClassEntity.PrefetchPathGrades)
Dim lessonPath As SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPathElement2 = classPath.SubPath.Add(ClassEntity.PrefetchPathLessonPlans)
Dim standardsPath As PrefetchPathElement2 = lessonPath.SubPath.Add(LessonPlanEntity.PrefetchPathStandardsCollectionViaLessonStandard)
Dim districtsBucket As New RelationPredicateBucket()
Dim standardsPredicate As New PredicateExpression()
' GetStandardCategoryPredicate returns a Range predicate full standardIds
standardsPredicate = GetStandardCategoryPredicate(categoryIds)
lessonPath.FilterRelations.Add(LessonPlanEntity.Relations.LessonStandardEntityUsingLessonPlanId)
lessonPath.FilterRelations.Add(LessonStandardEntity.Relations.StandardEntityUsingStandardId)
lessonPath.Filter.Add(standardsPredicate)
standardsPath.Filter.Add(standardsPredicate)
The query that filters out the standards looks like this (cleaned up from Profile Analyzer)
SELECT DISTINCT
Standard.StandardId, Standard.StandardCategoryId, Standard.StandardTypeVersionId, Standard.Id, Standard.Objective, Standard.Subject,
Standard.Deleted, Standard.Active, Standard.CreatedByUser, Standard.CreatedDate, Standard.ModifiedByUser, Standard.ModifiedDate
FROM LessonPlan INNER JOIN
LessonStandard AS LPA_L1 ON LessonPlan.LessonPlanId = LPA_L1.LessonPlanId INNER JOIN
Standard ON Standard.StandardId = LPA_L1.StandardId
WHERE (LPA_L1.LessonPlanId = 60) OR
(LPA_L1.LessonPlanId = 71) OR
(LPA_L1.LessonPlanId = 72) AND (Standard.StandardId IN (20821, 20822, 20823, 20824, 20825, 20826, 2........
If I run that query in Enterprise Manager without this..
(LPA_L1.LessonPlanId = 60) OR
(LPA_L1.LessonPlanId = 71) OR
(LPA_L1.LessonPlanId = 72) AND
the correct standards returned... UNFORTUNATELY, I can't figure out how to make that happen with my LLBLGen objects...
Please help... I'm pretty much completely out of solutions...