Skip to content

Commit be5d8e4

Browse files
committed
Updated AutoMapper to version 9.0.0
1 parent f04445f commit be5d8e4

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

ASP.NET Core/Services/AspNetCoreTemplate.Services.Mapping/AspNetCoreTemplate.Services.Mapping.csproj

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

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="AutoMapper" Version="8.1.1" />
16+
<PackageReference Include="AutoMapper" Version="9.0.0" />
1717
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all">
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

ASP.NET Core/Services/AspNetCoreTemplate.Services.Mapping/AutoMapperConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public static class AutoMapperConfig
1212
{
1313
private static bool initialized;
1414

15+
public static IMapper MapperInstance { get; set; }
16+
1517
public static void RegisterMappings(params Assembly[] assemblies)
1618
{
1719
if (initialized)
@@ -46,7 +48,7 @@ public static void RegisterMappings(params Assembly[] assemblies)
4648
map.CreateMappings(configuration);
4749
}
4850
});
49-
Mapper.Initialize(config);
51+
MapperInstance = new Mapper(new MapperConfiguration(config));
5052
}
5153

5254
private static IEnumerable<TypesMap> GetFromMaps(IEnumerable<Type> types)

ASP.NET Core/Services/AspNetCoreTemplate.Services.Mapping/QueryableMappingExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static IQueryable<TDestination> To<TDestination>(
1717
throw new ArgumentNullException(nameof(source));
1818
}
1919

20-
return source.ProjectTo(membersToExpand);
20+
return source.ProjectTo(AutoMapperConfig.MapperInstance.ConfigurationProvider, null, membersToExpand);
2121
}
2222

2323
public static IQueryable<TDestination> To<TDestination>(
@@ -29,7 +29,7 @@ public static IQueryable<TDestination> To<TDestination>(
2929
throw new ArgumentNullException(nameof(source));
3030
}
3131

32-
return source.ProjectTo<TDestination>(parameters);
32+
return source.ProjectTo<TDestination>(AutoMapperConfig.MapperInstance.ConfigurationProvider, parameters);
3333
}
3434
}
3535
}

0 commit comments

Comments
 (0)