9

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,874
  • 30
  • 99
  • 157

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
  • 11,194
  • 18
  • 82
  • 128
Mehdi Haghshenas
  • 2,433
  • 1
  • 16
  • 35
  • 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