Asp.net mvc 5 CRUD代碼自動產生工具- vs.net 2013 Saffolding功能擴充

來源:互聯網
上載者:User

標籤:

Asp.net mvc 5 CRUD代碼自動產生工具-Visual Studio.net2013 Saffolding功能擴充

上次做過一個《Asp.net webform scaffolding結合Generic Unit of Work & (Extensible) Repositories Framework代碼產生嚮導》

是生存Web Form的。

這次看到網上有產生MVC Saffolding擴充原作者的代碼 https://github.com/robinli/MVC5-Scaffolder

我在他的基礎上整合了Generic Unit of Work & (Extensible) Repositories Framework,並且添加分頁和查詢功能。

 

開發環境

Generic Unit of Work & (Extensible) Repositories Framework http://genericunitofworkandrepositories.codeplex.com/releases/view/113204

Happy.Scaffolding.MVC5.vsix (原始碼(https://github.com/neozhu/MVC5-Scaffolder) 如果覺得好請點贊 :)

Unity

Unity bootstrapper for asp.net mvc

Demo程式 http://files.cnblogs.com/files/neozhu/mvcscaffoldingDemo.zip

 

項目結構

 

新增實體和DbContext

Category,Product自己定義的實體物件

CategoryMetadata和ProductMetadata是通過嚮導產生主要用於驗證和顯示

建立一個新的Controller

建立metadata類的屬性

 

工具會自動產生以下幾個檔案

Controller

----CategoriesController.cs

Repositories

---CategoryRepository.cs

Services

---ICategoryService.cs

---CategoryService.cs

View

---Categories

-----Insert.cshtml

-----Edit.cshtml

-----EditForm.cshtml

-----Create.cshtml

 

具體代碼請看Demo程式

註冊服務

修改UnityConfig.cs

將需要用的Repository和Service註冊進去

運行調試

查詢頁面

編輯頁面

刪除功能

新增頁面,如果有外部索引鍵關聯會自動產生select選擇

 

後續改進

新增修改採用popup的方式,單頁面使用ajax form提交做到局部重新整理

新增一對多的修改和新增頁面

使用更多的ajax功能

Asp.net mvc 5 CRUD代碼自動產生工具- vs.net 2013 Saffolding功能擴充

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.