CRUD API服务

一个基于.NET的轻量级API,提供产品和客户的CRUD端点,使用EF Core InMemory。

  • by dushyanthkandiah
  • C#
  • 本地部署
  • 更新于
在 GitHub 查看 dushyanthkandiah/mcp-project

使用说明

MCPApi

最小。NET API的CRUD端点 Product 和 Customer 使用EF Core InMemory。

先决条件:

  • .NET 8 SDK或更高版本

在本地运行:

cd MCPApi
dotnet restore
dotnet run

API将于 https://localhost:5001 (Swagger在 /swagger).

示例请求(curl):

获取产品:

curl https://localhost:5001/api/products -k

创建产品:

curl -X POST https://localhost:5001/api/products -H "Content-Type: application/json" -d '{"name":"Orange","price":0.75}' -k

更新产品:

curl -X PUT https://localhost:5001/api/products/1 -H "Content-Type: application/json" -d '{"id":1,"name":"Updated","price":1.23}' -k

删除产品:

curl -X DELETE https://localhost:5001/api/products/1 -k