monstertjie_za
monstertjie_za

Reputation: 7823

Call Table Valued Function in LINQ query without .edmx

I have created a Table Valued Function in SQL.

I need to be able to call this function within my LINQ queries. I do not use the .edmx approach, I have a context class. My current version of Entity Framework is Version 6.0.0.0

All the examples I have seen so far is using the .edmx approach.

How can this be achieved?

Upvotes: 1

Views: 1540

Answers (1)

ocuenca
ocuenca

Reputation: 39376

Well, you could use SQLQuery<T> method on the Database class to execute your TVF:

int id = 1;
var query = context.Database.SqlQuery<Person>("Select * from [dbo].[tfn_GetPersonInfo](@p0)", id);
var results = query.ToList();

Update

Digging deep in this matter I found this article that could help you to find the solution you are trying to achieve. You can find the nuget package you need to install in this link

Upvotes: 2

Related Questions