I have the following code:
var query = Database.SqlQuery<int>(@"
SELECT CASE WHEN EXISTS (
SELECT 1
FROM v$session v, UsersXxxx u
WHERE v.Client_Info LIKE u.UserName || ';%'
AND v.UserName = :schemaName
AND u.SchemaName = :schemaName
AND v.module = 'XXXX.exe'
AND u.UserKey = :userKey)
THEN 1 ELSE 0 END AS LoggedIn FROM DUAL",
new OracleParameter("schemaName", schemaName),
new OracleParameter("userKey", userKey));
return query.First() != 0;
What creates "ORA-01008: not all related variables." I suspected something had happened with the way the variables were related, and ended up trying to do this:
var query = Database.SqlQuery<int>(@"
SELECT CASE WHEN EXISTS (
SELECT 1
FROM v$session v, UsersXxxx u
WHERE v.Client_Info LIKE u.UserName || ';%'
AND v.UserName = :schemaName
AND u.SchemaName = :schemaName
AND v.module = 'XXXX.exe'
AND u.UserKey = :userKey)
THEN 1 ELSE 0 END AS LoggedIn FROM DUAL",
new OracleParameter("asdf", schemaName),
new OracleParameter("fdsa", schemaName),
new OracleParameter("userKey", userKey));
return query.First() != 0;
What works like a charm! I poked the docs and found an advertising message that said:
"Binding scalar parameters are supported by ODP.NET and Entity Framework. Entity Framework supports parameter binding by name. Position binding is not supported."
Somehow I think that the documents are lying to me, and he is trying to bind by position. I remember how this was fixed before EF support, but I can’t remember what the fix was, especially how to apply the same method to EF.
, kludgy, , - ? , ?