且构网

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

MVC - 从实体框架中的存储过程中选择

更新时间:2022-11-04 17:51:48

有一些简单的步骤来实现



1-从数据库转到并更新模型,并添加所需的存储过程



复杂类型在返回数据时映射您存储的过程字段。



3-并将该复杂类型映射到存储过程。并使用它作为您使用表。


I am new to ASP.NET MVC. I should create a page where users enters an order for their shops by central warehouse. The products and amounts are listed by a stored procedure from database. I have to show rows in a gridview which are calculated by the stored procedure. I want to insert the changed data in a table in SQL after the user make changes on the gridview. Users can call the saved doc back and make changes on it and save it again.

I can't build a strategy how that can be made. If I use Entity Framework I can show the SQL table rows in grid but it is not my goal. I have to let the SQL calculate first the data. Could you please give me some start point and steps to go ahead. I hope I could explain what I need.

There Are some simple steps to do that

1- Go and update model from database and add the required Stored procedure

2- create a complex type from model browser

in complex type map your Stored procedure fields as it returns the data.

3- and map that complex type to the stored procedure. and use it as you use table.