Support for Table Valued Functions in EF6 Code First?

前端 未结 6 927
走了就别回头了
走了就别回头了 2021-02-07 10:03

Is it possible to call a TVF in EF6 Code First?

I started a new project using EF6 Database first and EF was able to import a TVF into the model and call it just fine. <

6条回答
  •  面向向阳花
    2021-02-07 10:33

    I was able to access TVF with the code below. This works in EF6. The model property names have to match the database column names.

    List data =
                    db.Database.SqlQuery(
                    "select * from dbo.my_function(@p1, @p2, @p3)",
                    new SqlParameter("@p1", new System.DateTime(2015,1,1)),
                    new SqlParameter("@p2", new System.DateTime(2015, 8, 1)),
                    new SqlParameter("@p3", 12))
                .ToList();
    

提交回复
热议问题