Last post Jul 03, 2015 01:19 AM by Li Wang
Jul 02, 2015 11:00 AM|crusso|LINK
I am new to MVC and Entity Framework, but love the ease of the code and the code separation that allows for easier setup of unit testing.
I had used the ASP .NET three tier approach on separating the data access, business logic and front end. The database I have uses select stored procedures to retrieve data from the database. I know from watching several videos and reading many tutorials
that the purpose of the Entity Framework is the way it dynamically creates the select statement for you. However, I am forced to use the select stored procedures because some of the information that is retrieved comes from a AS/400 Linked Server.
Is there a way to create the Entities of Entity Framework based off of the results from these stored procedures?
Below is an example of one of the Select Stored Procedures.
exec SelectAgreement @UserName=default,@CustomerNumber=default,@CustomerName=default,@IsATS=1,@ServiceKit='ROSA7005 ',@TermStart=default,@TermEnd=default,@WorkTypePK=default,@ScheduleTypePK=default,@AgreementNumber='0000517256',@Status=default
Any direction would be most appreciated.
Jul 03, 2015 01:19 AM|Li Wang|LINK
Thank you for your post.
As an Object Relational Mapping tool, the Entity Framework allows you to use stored procedures in the Entity Data Model instead of, or in combination with, its automatic command generation. When designing your model, you can:
1.specify that EF should use your stored procedures for inserting, updating, or deleting entities.
2.create model functions to call query stored procedures that return entities or results that do not match any of the entities in your model.
3.provide functions that call actions in the database but do not return data at all, such as performing a sweeping update across rows in a table.
4.define a stored procedure within custom functions directly in your model without it existing in the database.
5.map modification stored procedures to entities that are based on database views, eliminating EF’s need for direct table access.
For more information, link below is for your reference.
Hoping my reply could be helpful to you.