我很困惑我應該使用哪種型別的專案,因為我是 ASP.NET 和整個編程的新手。
我得到了創建網頁來管理員工的說明。
指令是:
- 帶有 3 個按鈕的導航選單
- 3 頁顯示員工、職位、過去的員工
- 編輯、添加、洗掉和創建員工
員工必須在服務器上,資料必須保存在 SQL 資料庫中(總是只有一個客戶端)。
我應該使用的技術:
客戶
- SASS、LESS 或 CSS(引導程式)
- Vue.js、VueCLI
- 打字稿
服務器
- ASP.NET Core Web API
- Docker 容器(Linux 作業系統)
- 資料庫:SQL
我嘗試使用 ASP.NET Core Web App 在 ASP.NET Core 5.0 中構建應用程式,但我不確定它是否是正確的專案型別,因為說明中的服務器技術是 ASP.NET Core Web API。
在說明中,我學習了 ASP.NET Web API 2,但只有沒有介面的 web api 專案示例。
我真的很迷茫我該怎么做。由于混淆,我多次洗掉了該專案。
可以請人幫助我嗎?謝謝!
uj5u.com熱心網友回復:
"I'm confused what type of project should I use because I'm newbie to ASP.NET and programing as a whole?"
根據您的描述和要求,您應該 在同一解決方案中擁有一個
client-side (frontend) project和一個。server-side (backend project)您可以按照以下步驟操作。
Client: Frondtend Project:
對于
client-side vue.js專案,您可以采取如下專案。請看螢屏截圖。

注意:有關更多詳細資訊,您可以查看我們的
注意:有關更多詳細資訊,您可以查看我們的
For details you could check
official document here
Your Domain Class:Based on your description you should have
employee domain classfor exaple an imaginaryemployee classlike below:public class Employee { public Guid Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } }
ApplicationDbContext:public class ApplicationDbContext: DbContext { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } public DbSet<Employee> Employee { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { // base.OnModelCreating(modelBuilder); modelBuilder.Entity<Employee>().ToTable("Employee"); } }Note:
You should similar
SQL Tableon your database, to make is easier here I am providing the Database script as well.
SQL Script:CREATE TABLE [Employee] ( Id UNIQUEIDENTIFIER PRIMARY KEY default NEWID(), [FirstName] [varchar](50) NULL, [LastName] [varchar](50) NULL, [Email] [varchar](50) NULL, )
Controller:[Route("api/[controller]")] [ApiController] public class UnitOfWorkEmployeeController : ControllerBase { private readonly ILogger<UnitOfWorkEmployeeController> _logger; private readonly IUnitOfWork _unitOfWork; public UnitOfWorkEmployeeController( ILogger<UnitOfWorkEmployeeController> logger, IUnitOfWork unitOfWork) { _logger = logger; _unitOfWork = unitOfWork; } [HttpGet] public async Task<IActionResult> Get() { var employees = await _unitOfWork.Employee.All(); return Ok(employees); } } }Note: If you need more details steps reagrding the best practice and implementation you
could have a look here in this threadHope above steps guided you accordingly to implement your requirements.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/457084.html
標籤:asp.net 核心 asp.net-core-webapi


