views:

92

answers:

0

We are working with LLBLGen v2.6 and trying to pull back records which do not have a certain relation. This relation is a category with a one to many mapping, and one of our entities can have zero or many categories. We want the ones with zero.

We have tried the following linq query, with little success. NoCategories is a boolean intended to indicate that we only want the people who have no categories assigned to them:

var linq = new LinqMetaData(Adapter);
var NoCategories = true;
List<Int32> selectedCategories = {1,2,3,4,5}.ToList();

var people = from people in linq.People_Table
                             join category in linq.Categories on people.ID equals category.Module_ID into categoriesRelation
                             from category in categoriesRelation.DefaultIfEmpty()
                             where (selectedCategories.Count == 0 && !NoCategories 
                                     || selectedCategories.Contains(category.Category_ID) 
                                     || (NoCategories && categoriesRelation.Any()))
                             select people;

We get the following error:

SD.LLBLGen.Pro.DQE.SqlServer.NET20 error '80131508' 
Index was outside the bounds of the array. 

By the way, we are not working with nullable types in our llbl model.