[英]Call Table Valued Function in LINQ query without .edmx
I have created a Table Valued Function in SQL. 我已经在SQL中创建了表值函数。
I need to be able to call this function within my LINQ queries. 我需要能够在我的LINQ查询中调用此函数。 I do not use the
.edmx
approach, I have a context class. 我没有使用
.edmx
方法,我有一个上下文类。 My current version of Entity Framework is Version 6.0.0.0
我当前的Entity Framework版本是
Version 6.0.0.0
All the examples I have seen so far is using the .edmx
approach. 到目前为止,我所看到的所有示例都使用
.edmx
方法。
How can this be achieved? 如何做到这一点?
Well, you could use SQLQuery<T>
method on the Database
class to execute your TVF: 好了,您可以在
Database
类上使用SQLQuery<T>
方法执行TVF:
int id = 1;
var query = context.Database.SqlQuery<Person>("Select * from [dbo].[tfn_GetPersonInfo](@p0)", id);
var results = query.ToList();
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
您可以在此链接中找到需要安装的nuget软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.