Using a package function or stored procedure within LINQ
Posted: 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?
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?