[英]How to map CONTAINSTABLE function in Entity Framework (code-first)?
Thanks to https://codefirstfunctions.codeplex.com/ , it is now possible to map functions in Entity Framework (code-first). 多亏了https://codefirstfunctions.codeplex.com/ ,现在可以在Entity Framework中映射功能(代码优先)。 I am trying to map CONTAINSTABLE function .
我正在尝试映射CONTAINSTABLE函数 。 How can pass the
table
argument? 如何传递
table
参数?
It might be good to use generic for that: 为此,最好使用泛型:
db.ContainsTable<MyEntity>(myTerm)
could translate into: 可以翻译成:
SELECT * FROM CONTAINSTABLE(MyEntities, *, @myTerm)
Should I somehow use CreateQuery for that? 我应该以某种方式使用CreateQuery吗?
(There are some older tries: [1] and hacky [2] . But with EF 6.1 and CF functions I am trying to find something more clean.) (有一些较早的尝试: [1]和hacky [2] 。但是,使用EF 6.1和CF函数,我试图找到更干净的东西。)
You can use DataTable for it. 您可以使用DataTable。
Create Parameter 创建参数
var dtparameter = new SqlParameter("paramname", SqlDbType.Structured); dtparameter.Value= dt; dtparameter.TypeName = "dbo.udt_tableName";
Pass this parameter to entity framework for calling tablevalue parameter. 将此参数传递给实体框架以调用tablevalue参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.