Page 1 of 1

Context.Query used in generation of EXISTS clause

Posted: Mon 12 Apr 2010 15:19
by crazypit
Hello,

I use the latest stable version of dotConnect for Oracle. When i run the following query, i get an exception.

(from objCustomer in dataContext.Customers
where
(dataContext.Query(
"SELECT cu_id FROM vw_root_cu_code where root_par_code = '10385888'").Select(
a => a)).Contains(objCustomer.Id)
select objCustomer).ToList()

ArgumentNullException
Value cannot be null.
Parameter name: key

What i'm trying to do is to generate this simple SQL:

SELECT A.* FROM CUSTOMERS A WHERE EXISTS (SELECT VW.CU_ID FROM VW_ROOT_CODE VW WHERE VW.ROOT_PAR_CODE = '10385888' AND VW.CU_ID = A.CU_ID)

ATTENTION! I don't have the option to generate an Entity for the view, because it is created dynamically through configuration by the application user, therefore the use of the Query method is mandatory and i cannot project to a specific Entity.

I really don't understand the need for that when generating an EXISTS clause. There is not a requirement to know the structure of the inner table. It can be anything, as long as i provide a Name with an alias plus the key column name prefixed with the alias...

Posted: Wed 14 Apr 2010 13:33
by AndreyR
The approach you are using is valid, I have reproduced the problem in our code.
I will let you know as soon as it is fixed.

Posted: Wed 28 Apr 2010 08:28
by AndreyR
There is a workaround in this case. Use the following code:

Code: Select all

(from objCustomer in dataContext.Customers 
where 
(dataContext.Query( 
"SELECT cu_id as \"c1\" FROM vw_root_cu_code where root_par_code = '10385888'").Select( 
a => a)).Contains(objCustomer.Id) 
select objCustomer).ToList()
This code will work in the next build.

Posted: Wed 28 Apr 2010 09:02
by crazypit
I already have an other workaround.

Will wait for the proper implementation in the next build. Thanks!

Posted: Thu 01 Jul 2010 15:46
by crazypit
Is this one fixed in version 5.70?

Posted: Fri 02 Jul 2010 09:59
by AndreyR
Yes, this problem was fixed in the 5.70.140 build of dotConnect for Oracle.