摘要:
电脑安装了多个dotnet版本,该如何进行切换 使用 global.json 文件指定要使用的版本。您可以使用以下命令创建 global.json 文件:dotnet new globaljson --sdk-version <version> --force。该文件将存储在当前项目SDK版本的文件 阅读全文
2024年1月7日 #
摘要:
如何使用数据库 创建DataContext.cs using Microsoft.EntityFrameworkCore; using PokemonReviewApp.Models; namespace PokemonReviewApp.Data { public class DataContex 阅读全文
摘要:
切换到sqlite数据库 using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext<DataContext>(options 阅读全文
摘要:
GameStore.Api/Dtos.cs using System.ComponentModel.DataAnnotations; namespace GameStore.Api.Dtos; public record GameDto(int Id, string Name, string Gen 阅读全文
摘要:
原先的模式 GamesEndpoints.cs public static class GamesEndpoints { public static RouteGroupBuilder MapGamesEndpoints(this IEndpointRouteBuilder endpoints) { 阅读全文
摘要:
dotnet ef migrations add InitialCreate --output-dir Data/Migrations dotnet ef database update 阅读全文
摘要:
接口的扩展方法 定义 当我们在C#中定义接口时,有时候我们希望为接口添加一些额外的方法,但是我们又不想修改接口本身。这时,接口的扩展方法就派上用场了。 接口的扩展方法允许我们在不改变接口定义的情况下,为接口添加新的方法。这些方法可以像实例方法一样调用,但实际上它们是静态方法。 例子 假设我们有一个接 阅读全文
摘要:
generate assets for build and dbug 阅读全文