且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架中的存储过程

更新时间:2023-12-06 17:18:52

现在你不能 - 你必须使用您的模型中定义的实体(虽然我认为基本的标量类型,如INT应该也可以工作)。

For now you cannot - you have to use one of the entities defined in your model (although I thought basic scalar types like INT should work, too).

事情应该会比EF4好多了 - 2010年初。

Things should get a lot better with EF4 - due out in late 2009 or early 2010.

有关这些新功能的一些信息,请参阅这些文章:

See these articles for some info on those new features:

  • A big step for Stored Procedures in EF4
  • Complex Types in the EDM Designer in EF4 and a look at updating complex types in code

如果您的存储过程纯粹用于记录,那么我可能只是在实体框架上下文,只是调用存储过程的好老式ADO.NET方式....为什么甚至把所有这一切放在EF上下文中?您不会使用此日志记录服务来检索,操作和存储数据 - 只需使静态方法成为静态类 - 保持简单!

If your stored proc is purely for logging, I would probably just surface it outside the Entity Framework context and just call the stored procedure the good old-fashioned ADO.NET way.... why even bother putting all of that into an EF context? You're not retrieving, manipulating and storing data with this logging service - just make it a static method on a static class - keep it simple!

Marc