automapper-5

Configuring AutoMapper to fulfil ITypeConverter<,> constructor dependecies with Autofac

巧了我就是萌 提交于 2019-12-07 16:10:44
问题 My first time working with Autofac to inject AutoMapper's IMapper interface into classes that have an object mapping requirement. I have made some progress, with a little help, getting the various dependencies added to AutoMapper's register using Assembly Scanning: builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()) .AsClosedTypesOf(typeof(ITypeConverter<,>)) .AsImplementedInterfaces(); builder.RegisterAssemblyTypes(typeof(AutoMapperExtensions).Assembly) .AssignableTo

Polymorphic Mapping of Collections with AutoMapper

那年仲夏 提交于 2019-12-07 10:33:38
问题 TL;DR: I'm having trouble with Polymorphic mapping. I've made a github repo with a test suite that illustrates my issue. Please find it here: LINK TO REPO I'm working on implementing a save/load feature. To accomplish this, I need to make sure the domain model that I'm serializing is represented in a serialization-friendly way. To accomplish this I've created a set of DTOs that contain the bare-minimum set of information required to do a meaningful save or load. Something like this for the

Configuring AutoMapper to fulfil ITypeConverter<,> constructor dependecies with Autofac

倾然丶 夕夏残阳落幕 提交于 2019-12-06 02:18:19
My first time working with Autofac to inject AutoMapper's IMapper interface into classes that have an object mapping requirement. I have made some progress, with a little help , getting the various dependencies added to AutoMapper's register using Assembly Scanning: builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()) .AsClosedTypesOf(typeof(ITypeConverter<,>)) .AsImplementedInterfaces(); builder.RegisterAssemblyTypes(typeof(AutoMapperExtensions).Assembly) .AssignableTo<Profile>().As<Profile>(); builder.Register(context => { var profiles = context.Resolve<IEnumerable<Profile>

Cannot map from ViewModel to ApplicationUser in AutoMapper 5

女生的网名这么多〃 提交于 2019-12-04 05:11:53
问题 I have a Student class inherited from ApplicationUser base class (ASP.NET Identity) and there is a ViewModel of it called StudentViewModel as shown below: Entity Classes: public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int> { public string Name { get; set; } public string Surname { get; set; } //code omitted for brevity } public class Student: ApplicationUser { public int? Number { get; set; } } ViewModel: public class

EF & Automapper. Update nested collections

 ̄綄美尐妖づ 提交于 2019-12-03 12:52:59
问题 I trying to update nested collection (Cities) of Country entity. Just simple enitities and dto's: // EF Models public class Country { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<City> Cities { get; set; } } public class City { public int Id { get; set; } public string Name { get; set; } public int CountryId { get; set; } public int? Population { get; set; } public virtual Country Country { get; set; } } // DTo's public class CountryData : IDTO {

EF & Automapper. Update nested collections

£可爱£侵袭症+ 提交于 2019-12-03 02:30:21
I trying to update nested collection (Cities) of Country entity. Just simple enitities and dto's: // EF Models public class Country { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<City> Cities { get; set; } } public class City { public int Id { get; set; } public string Name { get; set; } public int CountryId { get; set; } public int? Population { get; set; } public virtual Country Country { get; set; } } // DTo's public class CountryData : IDTO { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<CityData> Cities {

Mapper not initialized, When Use ProjectTo()

人盡茶涼 提交于 2019-11-30 17:17:09
I Use Automapper 5.2.0 In My Project. When I Use ProjectTo() In Code Get This Error: Mapper not initialized. Call Initialize with Appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance. Service Code public async Task<FreelancerProfileViewModel> GetFreelancerProfile() { var id = Guid.Parse(_identity.GetUserId()); var model = await

Migrating to AutoMapper 5 - Circular references

无人久伴 提交于 2019-11-29 23:32:53
问题 I'm having a System.StackOverflowException when trying to Map something in AutoMapper 5 that worked previously with AutoMapper 4. After googling a bit around I found out that it caused by Circular references. The AutoMapper Documentation says: Previously, AutoMapper could handle circular references by keeping track of what was mapped, and on every mapping, check a local hashtable of source/destination objects to see if the item was already mapped. It turns out this tracking is very expensive,