基于asp.net core webapi的商品管理系统Api开发 必备基础知识
2021-01-08 10:28
标签:file ica runtime origin enum tps 配置 depend iap .NET CORE 中使用AutoMapper进行对象映射 参考文档: https://blog.csdn.net/weixin_37207795/article/details/81009878 2 路由基础 参考文档: https://www.cnblogs.com/aehyok/p/3449851.html 配置代码 基于asp.net core webapi的商品管理系统Api开发 必备基础知识 标签:file ica runtime origin enum tps 配置 depend iap 原文地址:https://www.cnblogs.com/xiewenyu/p/13125117.html1 automapper
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;
using Xwy.Domain.Dtos.Product;
using Xwy.Domain.Dtos.UserInfo;
using Xwy.Domain.Entities;
namespace Xwy.Domain
{
public class AutoMapperConfigs : Profile
{
//添加你的实体映射关系.
public AutoMapperConfigs()
{
//Product转ProductDto.
CreateMap
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Xwy.Domain;
using Xwy.Domain.DbContexts;
using Xwy.Domain.Dtos.UserInfo;
using Xwy.Domain.Entities;
namespace Xwy.WebApiDemo.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class UserInfoesController : ControllerBase
{
private readonly VueShopDbContext _context;
private readonly IMapper _mapper;
public UserInfoesController(VueShopDbContext context,IMapper mapper)
{
_context = context;
_mapper = mapper;
}
// GET: api/UserInfoes
[HttpGet]
public async Task
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Xwy.Domain;
using Xwy.Domain.DbContexts;
namespace Xwy.WebApiDemo
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext
下一篇:c#出现可访问性不一致的情况
文章标题:基于asp.net core webapi的商品管理系统Api开发 必备基础知识
文章链接:http://soscw.com/essay/40907.html