I'm trying to figure out the way to get all records from a table that ha开发者_如何学Pythonve a specific column value AND that are NOT into a relational (many to many) table. Here's the model view:
http://i.stack.imgur.com/mcCzZ.png
I need all "testaction" with UserGroups_ID X, which can be done with:
from ta in qasEntities.TestActions
where ta.UserGroups_ID.Equals(selectedUsergroupsId)
select ta
How can I add a clause which would state: and where testaction has no relation to testcase
Thanks
You can use Any()
to see if there are any records.
Something like this:
from ta in qasEntities.TestActions
where ta.UserGroups_ID.Equals(selectedUsergroupsId) &&
!qasEntities.TestCase.Any(x => x.UserGroups_ID.Equals(ta.UserGroups_ID)
select ta
What this does is that it will check if there are any TestCases with the given UserGroups_ID
and since there's a !
in front, it will say "Where there aren't any TestCases with UserGroups_ID
XXX
".
精彩评论