Skip to content

Commit 9901c7a

Browse files
Moving away from Automapper
1 parent 05da9cb commit 9901c7a

File tree

4 files changed

+13
-30
lines changed

4 files changed

+13
-30
lines changed

SampleWebApiAspNetCore/Controllers/v1/FoodsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using AutoMapper;
2-
using Microsoft.AspNetCore.JsonPatch;
1+
using Microsoft.AspNetCore.JsonPatch;
32
using Microsoft.AspNetCore.Mvc;
43
using SampleWebApiAspNetCore.Dtos;
54
using SampleWebApiAspNetCore.Entities;
@@ -8,6 +7,7 @@
87
using SampleWebApiAspNetCore.Models;
98
using SampleWebApiAspNetCore.Repositories;
109
using System.Text.Json;
10+
using MapsterMapper;
1111

1212
namespace SampleWebApiAspNetCore.Controllers.v1
1313
{

SampleWebApiAspNetCore/MappingProfiles/FoodMappings.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

SampleWebApiAspNetCore/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using Mapster;
22
using Microsoft.AspNetCore.Mvc.ApiExplorer;
33
using Microsoft.AspNetCore.Mvc.Infrastructure;
44
using Microsoft.AspNetCore.Mvc.Routing;
@@ -7,7 +7,6 @@
77
using Newtonsoft.Json.Serialization;
88
using SampleWebApiAspNetCore;
99
using SampleWebApiAspNetCore.Helpers;
10-
using SampleWebApiAspNetCore.MappingProfiles;
1110
using SampleWebApiAspNetCore.Repositories;
1211
using SampleWebApiAspNetCore.Services;
1312
using Swashbuckle.AspNetCore.SwaggerGen;
@@ -40,7 +39,7 @@
4039
builder.Services.AddDbContext<FoodDbContext>(opt =>
4140
opt.UseInMemoryDatabase("FoodDatabase"));
4241

43-
builder.Services.AddAutoMapper(typeof(FoodMappings));
42+
builder.Services.AddMapster();
4443

4544
var app = builder.Build();
4645

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="AutoMapper" Version="12.0.1" />
11-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
12-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.2" />
13-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
14-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.2" />
16-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
17-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.24" />
10+
<PackageReference Include="Mapster" Version="7.4.0" />
11+
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
12+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.8" />
13+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.8" />
16+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
17+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.7" />
1818
</ItemGroup>
1919

2020
</Project>

0 commit comments

Comments
 (0)