简体   繁体   English

如何在实体框架中映射CONTAINSTABLE函数(代码优先)?

[英]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。

  1. Create 'DataTable' var dt=new DataTable() 创建'DataTable'var dt = new DataTable()
  2. Create Columns and Rows ot table 创建表的行和列
  3. 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.

相关问题 实体框架6代码优先的存储过程映射到复杂对象 - Entity Framework 6 code-first stored procedure map to complex objects 如何在Entity Framework 6代码优先方法中MAP选择存储过程? - How to MAP select stored procedure in Entity Framework 6 code-first approach? 如何在Entity Framework代码优先方法中映射自我的递归关系 - How to map recursive relation on self in Entity Framework code-first approach 如何使用Entity Framework代码优先映射带有复合键的继承表? - How do I map an inherited table with a composite key using Entity Framework code-first? 如何在实体框架代码优先中创建具有自引用的模型? - How to create a model with self reference in Entity Framework Code-First? 如何正确地促进实体框架代码优先迁移到生产中? - how to properly promote Entity Framework code-first migrations into production? 如何在Entity Framework代码优先中设置空外键 - How to set null foreign key in Entity Framework code-first 如何在Entity Framework代码优先中处理自我引用? - How to handle self references in Entity Framework code-first? 如何在代码优先实体框架中提供数据库配置设置? - How to provide database configuration settings in code-first Entity Framework? 如何在实体框架 6(代码优先)中调用存储过程? - How to call Stored Procedure in Entity Framework 6 (Code-First)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM