Using a package function or stored procedure within LINQ

Using a package function or stored procedure within LINQ

Postby dcarter9 » Thu 11 Aug 2011 19:54

I'm hoping someone can point me in the right direction. I would like to use a package function within my query using LINQ like so:

var query = from c in context.SomeEntity
select new
{
FieldA = c.FieldA,
FieldB = c.FieldB,
FieldC = context.SomePackageFunction(c.ID)
};

I have created the SomePackageFunction in my context and it works fine on its own, but not when combined within a LINQ query.

I am hoping this would result in a PL/SQL query similar to:

SELECT
1 AS [C1],
[Extent1].[FieldA] AS [FieldA],
[Extent1].[FieldB] AS [FieldB],
[MySchema].[MyPackage].[MyFunction]([Extent1].[ID]) AS [C2]
FROM [MySchema].[MyTable] AS [Extent1]

How can I accomplish this in a code-first approach?
dcarter9
 
Posts: 2
Joined: Thu 11 Aug 2011 19:43

Postby dcarter9 » Thu 11 Aug 2011 20:11

I should also mention that when I attempt to execute the LINQ query above, I get a TargetParameterCountException : Parameter count mismatch.

Even if I try to hard-code the parameter values of the function, I get this exception.

I am in need of a way to combine querying both entities and functions in order to hydrate new objects using LINQ. We are using legacy Oracle ERP where many of the data items are obtained from calling packages.
dcarter9
 
Posts: 2
Joined: Thu 11 Aug 2011 19:43

Postby Shalex » Mon 15 Aug 2011 15:12

You can trace the SQL query that is sent to the server and parameters collection via dbMonitor.
Download link: http://www.devart.com/dbmonitor/dbmon3.exe
Documentation: http://www.devart.com/dotconnect/oracle ... nitor.html

If this doesn't help, please send us a small test project with the corresponding DDL/DML script to reproduce the issue in our environment.
Shalex
Devart Team
 
Posts: 7709
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle