In LINQ2SQL it was possible to set the return type of a stored procedure to auto generated. I am unable to do so with the Entity Framework.
在LINQ2SQL中,可以将存储过程的返回类型设置为自动生成。我无法使用实体框架这样做。
I want to set the return type of a stored procdure to auto-generated with the Entity Framework. Is this possible?
我想将存储过程的返回类型设置为使用Entity Framework自动生成。这可能吗?
Kind regards.
1 个解决方案
#1
1
Entity Framework V1 has good support for working with Stored Procedures directly with entities (as Insert/Update/Delete operations) but as you have discovered, out of the box the support for SPs as functions on your ObjectContext is poor. They pretty much always have to map perfectly to an existing entity in your model as the expectation was you would then do changes to the returned results from the SP and hence would want to work with them as entities. Clearly this is not always the case.
实体框架V1对直接使用实体的存储过程(作为插入/更新/删除操作)提供了很好的支持,但是正如您所发现的那样,开箱即用的支持SP作为ObjectContext上的函数很差。它们几乎总是必须完美地映射到模型中的现有实体,因为期望您随后会对SP返回的结果进行更改,因此希望将它们作为实体使用。显然情况并非如此。
Thankfully there are extensions for EF v1 which include improved support for SPs. Download the extensions here.
值得庆幸的是,EF v1有扩展,包括对SP的改进支持。在此处下载扩展程序。
EF v2 will have better support.
EF v2将获得更好的支持。
#1
1
Entity Framework V1 has good support for working with Stored Procedures directly with entities (as Insert/Update/Delete operations) but as you have discovered, out of the box the support for SPs as functions on your ObjectContext is poor. They pretty much always have to map perfectly to an existing entity in your model as the expectation was you would then do changes to the returned results from the SP and hence would want to work with them as entities. Clearly this is not always the case.
实体框架V1对直接使用实体的存储过程(作为插入/更新/删除操作)提供了很好的支持,但是正如您所发现的那样,开箱即用的支持SP作为ObjectContext上的函数很差。它们几乎总是必须完美地映射到模型中的现有实体,因为期望您随后会对SP返回的结果进行更改,因此希望将它们作为实体使用。显然情况并非如此。
Thankfully there are extensions for EF v1 which include improved support for SPs. Download the extensions here.
值得庆幸的是,EF v1有扩展,包括对SP的改进支持。在此处下载扩展程序。
EF v2 will have better support.
EF v2将获得更好的支持。