8

Thanks to https://codefirstfunctions.codeplex.com/, it is now possible to map functions in Entity Framework (code-first). I am trying to map CONTAINSTABLE function. How can pass the table argument?

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?

(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.)

Community
  • 1
  • 1
TN.
  • 18,204
  • 26
  • 90
  • 150

1 Answers1

0

You can use DataTable for it.

  1. Create '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.

mehdi lotfi
  • 10,716
  • 16
  • 77
  • 124
Mehdi Haghshenas
  • 2,303
  • 1
  • 13
  • 33
  • You mean this http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx `DataTable`? How use this in LINQ in the Entity Framework? – TN. Aug 18 '14 at 11:01