I have two tables (TestSets and TestSetMembers) with a many to many relationship defined in an Entity Framework. In other words, one TestSet can have one or more TestSetMembers belonging to it. And one TestSetMember can belong to one or more TestSets.
I can not understand why the following query doesn’t work ( returns an empty set) with the following definition of tsMbrs:
TestSetMember[] tsMbrs.
var testSetQuery = (from ts in tsMbrs[0].TestSets
where tsMbrs.All(tsm => tsm.TestSets.Contains(ts))
select ts).ToArray()
At the end of the query testSetQuery is empty. It should have found one TestSet that is used by two different test set members.
I have tried the following queries and have found the proper TestSet.
var tsq1 = (from ts in tsMbrs[0].TestSets
where (tsMbrs[0].TestSets.Contains(ts))
var tsq2 = (from ts in tsMbrs[1].TestSets
where (tsMbrs[1].TestSets.Contains(ts))
tsq1 = tsq2 and contain the proper TestSet.
However the following returns an empty set.
var tsq3 = (from ts in tsMbrs[0].TestSets
where (tsMbrs[1].TestSets.Contains(ts))
select ts);
The only change between the three above queries are the Index values for
tsMbrs[].
Any help would be appreciated. Thanks.