Don't know if this is the correct forum, my apologies if not.
I'm new to LinQ and I'm having trouble converting the following TSQL query to a LinQ query:
SELECT r.*
FROM [Rule] r
INNER JOIN [RuleType] rt
ON r.[RuleTypeId] = rt.[RuleTypeId]
AND rt.[RuleCategoryId] = 1
AND 35 IN (SELECT DISTINCT c.StateId
FROM [Citation] c
WHERE r.[CitationId] = c.[CitationId]
UNION
SELECT DISTINCT a.StateId
FROM [Agency] a
WHERE r.[AgencyId] = a.[AgencyId])
The DB looks like:
--------------- ------------------
| Rule | | Rule Type | ------------------
--------------- -----------------| | RuleCategory |
| RuleId | -----+| RuleTypeId | ------------------
| RuleName | | | RuleCategoryId |>o-------------------+| RuleCategoryId |
| RuleDesc | | | RuleType | | RuleCategory |
| RuleTypeId |>o--| -----------------| -------------- ------------------
| CitiationId |>o------- | Citation |
| AgencyId |>o-- | -------------|
--------------- | |---------------------+| CitationId |
| | Citation |
| | StateID |
| -------------- --------------
| | Agencey | V
| -------------- o
------+| AgencyId | |
| AgencyName | |
| AgencyDesc | |
| StateId |>o-----------\|
-------------- |
|
+
-------------
| State |
-------------
| StateId |
| StateName |
-------------