I just tried this and it seems to work. First create a class as you would to be able to map the return from your DbContext. In your case you just call the Pipelined table function from Oracle. I used a TVF in SQL to demonstrate. The TVF returned 3 columns of data, 2 INT and 1 NVarChar.
public class ReturnThreeColumnTableFunction
{
public int ColumnOne { get; set; }
public int ColumnTwo { get; set; }
public string ColumnThree { get; set; }
}
Then based on your Oracle Pipelined function, (see my MSSQL TVF below)
/* SQL TableValuedFunction */
ALTER FUNCTION [dbo].[ReturnThreeColumnTableFunction]
(
@ColumnOne INT,
@ColumnTwo INT,
@ColumnThree NVARCHAR(10)
)
RETURNS TABLE
AS
RETURN
(
SELECT @ColumnOne AS ColumnOne, @ColumnTwo AS ColumnTwo, @ColumnThree AS ColumnThree
)
Then in your DbContext class you setup your CodeFirst entities, be sure to add the complex type in the OnModelCreating method.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.ComplexType<ReturnThreeColumnTableFunction>();
modelBuilder.ComplexType<ReturnThreeColumnTableFunction>().Property(x => x.ColumnOne).HasColumnName("ColumnOne");
modelBuilder.ComplexType<ReturnThreeColumnTableFunction>().Property(x => x.ColumnTwo).HasColumnName("ColumnTwo");
modelBuilder.ComplexType<ReturnThreeColumnTableFunction>().Property(x => x.ColumnThree).HasColumnName("ColumnThree");
}
Then you return this easily using the SqlQuery
var items = context.Database.SqlQuery<ReturnThreeColumnTableFunction>("SELECT * FROM dbo.ReturnThreeColumnTableFunction(1,2,'3')")
