Linq query - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Linq query

jake5958jake5958 Posts: 3Member
Don't know if this is the correct forum, my apologies if not.
[b]
I'm new to LinQ and I'm having trouble converting the following TSQL query to a LinQ query:[/b]


[color=Blue][size=1] 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])[/size][/color]


[b]The DB looks like:[/b]

[size=1]--------------- ------------------
| 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 |
-------------[/size][color=Green][/color]

Comments

Sign In or Register to comment.