urfnet / URF.Core

Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight.
https://github.com/urfnet
MIT License
309 stars 62 forks source link

Stored Procedures with URF.Core #36

Closed ydlkrishna closed 6 years ago

ydlkrishna commented 6 years ago

Is there any way to use Stored Procedures and binding to complex entity types which is available in URF.Net? If not any workarounds as we have lot of business logic already implemented in SQL Server DB and make use of it for new application development? Or we should go back and use EF6 with URF.Net or the combination of EF6 for SPs and EF Core for regular table entities or some else...

Thanks in advance, Krishna.

tonysneed commented 6 years ago

Thanks for your question. URF.Core and EF Core fully support executing stored procedures and mapping the results to complex types, which are now called owned types. Simply call IRepository.QueryableSql, passing the name of the stored procedure and its parameters.

At this point I would recommend URF.Core and EF Core over URF.Net and EF6. EF Core 2.1 has matured significantly and has filled in the gaps quite a bit. It can run cross-platform and is cloud-friendly, whereas EF6 is tied to Windows. We have also improved URF with the .Core version by eliminating confusing API's and factoring the packages so that you can opt out of Trackable Entities if you don't need it.

ydlkrishna commented 6 years ago

Thanks for your immediate reply @tonysneed . Do you have any Unit Test sample that work with SPs and assigned the result into a complex type? Also, do you have any tentative timeline to release the latet NuGet package on URF.Core?

tonysneed commented 6 years ago

There is a unit test, QueryableSql_Should_Allow_Composition, which you can look at. It doesn't use stored procedures, but here is a good article that might help. In terms of combining stored procs with owned types, I haven't tried it. But here is how you would do it.

tonysneed commented 6 years ago

Just published NuGet packages yesterday for URF.Core v1 RTM.