Rather simple code first structure (3 "nested" tables):
Code: Select all
public class Change
{
IColection Approvals {get;set;}
Status Status {get;set;}
}
public class Approval
{
public int ApprovalId {get;set;}
public int ChangeId {get;set;}
public bool CurrentlyActive {get;set;}
IColection ApprovalUser {get;set;}
}
pulbic class ApprovalUser
{
public int ApprovalUserId {get;set;}
public string sid {get;set;}
public bool Active {get;set;}
}
// not necessary to represent the behaviour
public class Status
{
public int StatusId {get;set;}
pulbic string Name {get;set;}
}
"Give me all approvals for the given user sid which are active.
Code: Select all
IQueryable changes = from c in changeRepo
where c.Status.Name == status &&
c.Approvals.Any(
a =>
a.CurrentlyActive == true &&
a.ApprovalUser.Any(au => au.Approver == sid && au.Active == true))
select c;
Code: Select all
SELECT
"GroupBy1".A1 AS C1
FROM
(
SELECT Count(1) AS A1
FROM CHG_DEVELOP."CHANGE" "Extent1"
INNER JOIN CHG_DEVELOP.REF_STATUS "Extent2" ON "Extent1".STATUS_ID = "Extent2".STATUS_ID
WHERE
(
( EXISTS
(
SELECT 1 AS C1
FROM
(
SELECT
"Extent3".CHANGE_APPROVAL_ID AS CHANGE_APPROVAL_ID,
"Extent3".IS_CURRENTLY_ACTIVE AS IS_CURRENTLY_ACTIVE
FROM CHANGE_APPROVAL "Extent3"
WHERE "Extent1".CHANGE_ID = "Extent3".CHANGE_ID
) "Project1"
WHERE ("Project1".IS_CURRENTLY_ACTIVE = 1) AND ( EXISTS
(
SELECT 1 AS C1
FROM CHANGE_APPROVAL_USER "Extent4"
WHERE ("Project1".CHANGE_APPROVAL_ID = "Extent4".CHANGE_APPROVAL_ID) AND (("Extent4".APPROVER_SID = 'E529322') AND ("Extent4".IS_ACTIVE = 1))
)
)
)) AND ("Extent2".NAME = :p__linq__1)) AND ("Extent1".CHANGE_NUMBER LIKE '%8%' ESCAPE '/')
) "GroupBy1"
Code: Select all
select * from Change "Extent1"
where exists
(
select 1 as c1
FROM
(
SELECT
"Extent3".CHANGE_APPROVAL_ID AS CHANGE_APPROVAL_ID,
"Extent3".IS_CURRENTLY_ACTIVE AS IS_CURRENTLY_ACTIVE
FROM CHANGE_APPROVAL "Extent3"
WHERE "Extent1".CHANGE_ID = "Extent3".CHANGE_ID
) "Project1"
)
on the following line in both the original and a generated sql."ORA-00904: "Extent1"."CHANGE_ID": invalid identifier"
> WHERE "Extent1".CHANGE_ID = "Extent3".CHANGE_ID
Oracle version:
Please fix, as we're getting really unhappy.Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
Dev Art versions:
Devart.Data, Version=5.0.272.0,
Devart.Data.Oracle, Version=6.30.172.0
Devart.Data.Oracle.Entity, Version=6.30.172.0