怪奇物语

怪奇物语

首页 新随笔 联系 管理

2024年1月7日 #

摘要: 电脑安装了多个dotnet版本,该如何进行切换 使用 global.json 文件指定要使用的版本。您可以使用以下命令创建 global.json 文件:dotnet new globaljson --sdk-version <version> --force。该文件将存储在当前项目SDK版本的文件 阅读全文
posted @ 2024-01-07 21:30 超级无敌美少男战士 阅读(2293) 评论(0) 推荐(0)

摘要: 如何使用数据库 创建DataContext.cs using Microsoft.EntityFrameworkCore; using PokemonReviewApp.Models; namespace PokemonReviewApp.Data { public class DataContex 阅读全文
posted @ 2024-01-07 21:30 超级无敌美少男战士 阅读(82) 评论(0) 推荐(0)

摘要: 切换到sqlite数据库 using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext<DataContext>(options 阅读全文
posted @ 2024-01-07 21:28 超级无敌美少男战士 阅读(222) 评论(0) 推荐(0)

摘要: GameStore.Api/Dtos.cs using System.ComponentModel.DataAnnotations; namespace GameStore.Api.Dtos; public record GameDto(int Id, string Name, string Gen 阅读全文
posted @ 2024-01-07 21:26 超级无敌美少男战士 阅读(30) 评论(0) 推荐(0)

摘要: 原先的模式 GamesEndpoints.cs public static class GamesEndpoints { public static RouteGroupBuilder MapGamesEndpoints(this IEndpointRouteBuilder endpoints) { 阅读全文
posted @ 2024-01-07 21:25 超级无敌美少男战士 阅读(29) 评论(0) 推荐(0)

摘要: dotnet ef migrations add InitialCreate --output-dir Data/Migrations dotnet ef database update 阅读全文
posted @ 2024-01-07 21:25 超级无敌美少男战士 阅读(38) 评论(0) 推荐(0)

摘要: 接口的扩展方法 定义 当我们在C#中定义接口时,有时候我们希望为接口添加一些额外的方法,但是我们又不想修改接口本身。这时,接口的扩展方法就派上用场了。 接口的扩展方法允许我们在不改变接口定义的情况下,为接口添加新的方法。这些方法可以像实例方法一样调用,但实际上它们是静态方法。 例子 假设我们有一个接 阅读全文
posted @ 2024-01-07 21:24 超级无敌美少男战士 阅读(82) 评论(0) 推荐(0)

摘要: generate assets for build and dbug 阅读全文
posted @ 2024-01-07 21:23 超级无敌美少男战士 阅读(40) 评论(0) 推荐(0)