I have a Visual Studio 2008 C# .NET 3.5 project using MySql 5.1.53 and MySql Connector/Net 6.4.4 on Windows 7 x64.
In my application I’m looking for items with no status for either upgrades or testcases, so I query the my database as:
var task_query = from task in task_list_.TaskSet
from tc in task.TestCases
where
(task.Upgrade != null && task.Upgrade.Status.Count == 0) ||
tc.Status.Count == 0
orderby task.Order
select task;
But, it never returns any items. If, however, I limit my query to only the upgrades and query like this:
var task_query = from task in task_list_.TaskSet
where
(task.Upgrade != null && task.Upgrade.Status.Count == 0)
orderby task.Order
select task;
I find the upgrades that have no status. Likewise, this query:
var task_query = from task in task_list_.TaskSet
from tc in task.TestCases
where
tc.Status.Count == 0
orderby task.Order
select task;
will successfully find test cases with no status.
How do I need to reform my original linq query to locate both test cases and upgrades where the status.count == 0?
Take the two separate queries and use a union to combine them.