Questions tagged [automapper]

A convention-based object-to-object mapper and transformer for .NET

Filter by
Sorted by
Tagged with
-3 votes
1 answer
37 views

AutoMapper - Need Help Ignoring Base Class Property [closed]

class BaseA { } class BaseB { public string SomeProperty; } class DerivedA: BaseA { } class DerivedB: BaseB { } CreateMap<BaseA, BaseB>() .ForMember(dest => dest.SomeProperty, opt =&...
Jacob Roberts's user avatar
0 votes
1 answer
82 views

How to map List<Guid> to List<Class> using Automapper?

public class A { public virtual ICollection<Person> People { get; set; } = new List<Person>(); } public class B { public List<Guid> People { get; set; } } CreateMap<B, A&...
Nikhil Vartak's user avatar
0 votes
1 answer
45 views

AutoMapper dictionary to class - how to ignore unsupported property mapping?

I'd like to convert dynamic objects of type Dictionary<string, object> to typed classes. Automapper allows that by default without need to create explicit map: https://docs.automapper.org/en/...
Ondrej's user avatar
  • 596
-1 votes
1 answer
116 views

AutoMapper with Custom Type Converter and DI throws AutoMapperMappingException

I'm examining a project which uses AutoMapper and Microsoft.Extensions.DependencyInjection. All Mappers works as expected, but for one - the only one - which uses a custom type converter. // there is ...
Maddin's user avatar
  • 306
0 votes
1 answer
52 views

AutoMapper 12.0.1 unit test failing for FindTypeMapFor method

We are updating Auto mapper from 10.1.1 to 12.0.1 in .netcore. After updating we got error for FindTypeMapFor. So I have added using AutoMapper.Internal; namespace. so that issue is resolved but in ...
sadasiva 's user avatar
1 vote
1 answer
97 views

The LINQ expression OrderBy DateTimeOffset.DateTime could not be translated

I have a .NET Core project in which I have implemented this GraphQL query. The query works correctly, but the sorting by date is not working. [UsePaging(MaxPageSize = 200, IncludeTotalCount = true)] [...
AmD's user avatar
  • 429
0 votes
0 answers
42 views

AutoMapper with ConstructUsing to map child properties not valid in test, but works in production

I am trying to test the usage of our AutoMapper profiles in our project. I have an object Source which I map to Destination, actually it has about 30 properties, but for this example it will be fine ...
Wolfware's user avatar
-1 votes
0 answers
40 views

Missing type map configuration or unsupported mapping. Mapping types: AsyncStateMachineBox`1 -> List`1 - ASP.NET Core 6 Web API

I am getting this error in my ASP.NET Core 6 Web API: Missing type map configuration or unsupported mapping. Mapping types: AsyncStateMachineBox1 -> List1 System.Runtime.CompilerServices....
Shefat-Hasnain's user avatar
0 votes
1 answer
43 views

.NET EF Core Automapper ProjectTo filtering is not working

I have the following piece of code var taskDTOs = await _repo.GetQueryable<TaskStatus>() .Where(s => s.Tasks.Any(t =>t.CompanyId == _userContext.CompanyId && t.UserId == ...
Nour Mawla's user avatar
-1 votes
2 answers
82 views

Unable to get Values from Enumeration using Automapper in ASP.NET Core C#

I am using PosgreSQL to return data into my Web API. I have created my DTO class like below: public class SuppressionItem { public long AccountId { get; set; } public ...
Ashok kumar's user avatar
  • 1,597
0 votes
0 answers
40 views

AutoMapper ignores ForMember calls on parameterized constructor construction of an target entity

Because my Issue on Github was closed im opening an thread here. In my option this is clearly a bug of AutoMappers behavior. Because this directly leads to unexpected errors. Therefore i directly ...
Dominik Pfeifer's user avatar
0 votes
0 answers
30 views

Complext Object Conditional Mapping in AutoMapper

It is my destination object and nested object : public class Category { public int Id { get; set; } public string CategoryName { get; set; } public string CategorryDescription { get; set; }...
Hakan Kaban's user avatar
0 votes
2 answers
105 views

How to use services in a c# AutoMapper Action

I have a profile set up: builder.Services .AddAutoMapper((IMapperConfigurationExpression a) => { a.AddProfile<GeneralMappingProfile>(); }); Here is the Profile: public class ...
Jimmyt1988's user avatar
  • 20.6k
0 votes
2 answers
61 views

Handle circular reference with entity framework or automapper

Im trying to learn and understand how to use entity framework and automapper with relations. And maby more specifically circular references. Lets say i have 3 objects: public class Author { public ...
Simon's user avatar
  • 1
0 votes
1 answer
99 views

C# Automapper and List of parent type not mapping childs

I've tried mapping the children of FirewallRule and when the controller receives the payload, firewallDto is not mapped with the DestinationPorts. The data is trimmed and the structure is stopping at ...
ICos's user avatar
  • 11
-1 votes
0 answers
25 views

Operation not supported on iOS for Automapper

I am using automapper to convert a DTO object to another object in Xamarin iOS. I'm receiving reflection errors that aren't supported on iOS. The Dto and target object both have a collection of sub-...
Richthofen's user avatar
  • 2,074
0 votes
1 answer
70 views

.NET 6 and AutoMapper

I'm trying to implement AutoMapper in my project of Hotels in ASP.NET; in .NET 5 it was working fine, but as I moved to .NET 6, I cannot figure out how to exchange this.GetType() in builder.Services....
Insikt's user avatar
  • 21
0 votes
1 answer
41 views

How to add custom Method to ProjectTo in AutoMapper?

I'm using .NET Core 7 and AutoMapper 12 and I'm trying to create a map from an Entity Framework query to a list of DTO's. As I need a list of DTO's, I'm using the .ProjectTo() function from AutoMapper ...
guirms's user avatar
  • 262
0 votes
0 answers
27 views

how to enable ExplicitExpansion globally

I'm using ProjectTo in AutoMapper and I want to set ExplicitExpansion globally, is there any way to customize it instead of this way? public class UserDetailResponseProfile : Profile { public ...
Vũ Văn Dương's user avatar
-1 votes
0 answers
28 views

Automapper with custom resolver throws error

I would like to convert a WelfareOfficeDto a WelfareOffice. To do this, it should use my resolver by retrieving the correct WelfareOffice from the database via EfCore using the WelfareOfficeDto.Id and ...
CCTB's user avatar
  • 1
0 votes
0 answers
71 views

In AutoMapper, how can I globally state that I *never* want property to be set in descendant classes?

When calling Services.AddAutoMapper(cfg => how can I specify globally that I never want the Timestamp property to be mapped into on any descendants of my AggregateRoot class? I have tried the ...
Peter Morris's user avatar
  • 21.1k
0 votes
1 answer
52 views

AutoMapper bringing data out of nowhere after Entity Framework Query

I'm using .NET Core 7 and Entity Framework Core 7.0.13 and AutoMapper 12.0.3 and I have the following query: var test = _context.Set<T> .AsNoTracking() .Include(m => m....
guirms's user avatar
  • 262
0 votes
0 answers
52 views

AutoMapper 12.0.1 Update Causes AssertConfigurationIsValid() Failures with Custom Value Resolvers

I have encountered an issue after updating AutoMapper from version 10.0.1 to 12.0.1. The following code is part of my mapping profile, which previously functioned correctly. However, after the update, ...
Umamaheswaran's user avatar
3 votes
1 answer
62 views

Configure two instance of same type for different constructors in autofac

I'm developing an ASP.NET project using .NET 6, Autofac for dependency injection, and AutoMapper for object mapping. In my project, I have two services, A and B, each of which requires its own ...
f soltanzadeh's user avatar
0 votes
1 answer
59 views

C# Automapper from flat view model to nested Dto

I'm trying to map a basically flattened view model to a Dto with nested objects. Having a hard time doing it since the view model properties have different names from the Dto. Here's an illustration ...
El_bosteador's user avatar
0 votes
0 answers
50 views

automapper - inject dependency in resolver

One of my fields needs a mapping from a database call hence I am using a resolver that takes a Repository instance to make a database call and return the result. I am using a Lazy static auto mapper ...
Shaggy's user avatar
  • 5,500
0 votes
2 answers
48 views

Automapper - How get joined table data

i've build example application with .Net Core 7 and trying use Automapper 12.0 and stucked in this situation. I want to sum values from Table HutangHistory which is joined (maybe) from my ...
Hafidz Fairiz's user avatar
0 votes
2 answers
55 views

Setup Automapper member mapping dynamically from a list

I have this source class: public class MyClass { public string Name { get; set; } public int Height { get; set; } } And this destination class (same class, but with properties in another ...
Daniele Arrighi's user avatar
0 votes
1 answer
54 views

AutoMapper throws NullReferenceException with property named 'Original' in mapping source where destination is a record

I am getting NullReferenceExceptions in a mapping where the source type has a property named 'Original' and the destination of the mapping is a record (as opposed to a class). This is with AutoMapper ...
Scott Munro's user avatar
  • 13.4k
0 votes
0 answers
34 views

What parameter types does ForAllMembers function accept?

I am trying to learn AutoMapper. I have this legacy class which I don't understand how it works. I have researched internet but can't find anything on for example what is op argument passed to ...
janci's user avatar
  • 233
-1 votes
1 answer
41 views

What is correct approach to mapping entities to CouchDB documents in a clean architecture? [closed]

I would like to use a Clean Architecture approach in my .NET Core Service - particularly, separate my entities and aggregates from CouchDocument models. If I understood correctly, then I should do the ...
VasiliyLu's user avatar
0 votes
0 answers
87 views

OData, EFCore DTO Error: Expression 'Example.DTOs.Models.ProcessDTO' in the SQL tree does not have a type mapping assigned

What I´m trying to do: I have an ASP.NET Core project with an ODataController. The ODataController returns DTOs and recevies ODataQueryOptions of type DTO. With Automapper included I can cast my Query ...
user3799376's user avatar
0 votes
0 answers
61 views

How to use typescript automapper(nartc/mapper) with Prisma js?

I try to make Prisma work with Automapper (to be able to map Models to Dtos and back). Prisma has schema.prisma where we define models, and that models are generated then automatically for us.. BUT as ...
Vlad Mosienko's user avatar
0 votes
0 answers
42 views

AutoMapper - deserialize dynamic value within collection not working

I'm trying to use automapper in order to fulfill the DTO mapping here, and I have the following situation: When storing Value into the database, I'm stringifying the JSON attribute using the following:...
Kiwanax's user avatar
  • 1,305
0 votes
0 answers
50 views

Problem with AutoMapper version 10.1.1 Cannot create an instance of type

I am using AutoMapper version 10.1.1 with custom converters for my models. I have extension method where I pass in IMapperConfigurationExpression. public static partial class AutoMapperConfigurator ...
daniel Kožul's user avatar
0 votes
1 answer
73 views

Domain object to entity model, EF loses tracking issue (DDD)

I'm trying to follow DDD but feel like I'm missing something. My solution is like: Domain project having Order and OrderItem classes (these classes have instance methods containing some business ...
Sami's user avatar
  • 3,714
0 votes
1 answer
33 views

AutoMapper (v9 & 10) maps successfully when Destination property missing in Source should cause failure

Is this a bug or is there an explanation? If I understand the AutoMapper documentation correctly, I should be failing when no Source member/mapping is found for Destination member https://docs....
austinavmfb's user avatar
0 votes
0 answers
69 views

AutoMapper Version="12.0.1" is not working with net7.0 in generic type object

[HttpGet("data")] public async Task<IEnumerable<SelectItem<int>>> GetDataList() { var _record = await _Repo.GetMyRecordDataList().ToListAsync(); //_record record is ...
Rabiranjan Singh's user avatar
0 votes
1 answer
81 views

Throw custom error when a mapping error occurs with Automapper in a ASP.NET Core 6 Web API project

I have an ASP.NET Core 6 Web API project and I am using AutoMapper. This is how I am configuring it in my Startup class: services.AddAutoMapper(Assembly.GetExecutingAssembly()); Is there a way to ...
Buda Gavril's user avatar
  • 21.5k
-1 votes
1 answer
32 views

The error of mapping two classes with auto mapper

I have two classes at the project level, I want to map them with Auto Mapper, but there is a mapping error, can you help me? public class RegisterVm { [Required] public string FirstName { get; ...
Hamed Salemi's user avatar
1 vote
1 answer
60 views

How to use a Mock in xunit passing a mapped entity

I'm trying to create an unit test using moq on xunit, but the test is failing, I guest is because of the mapper, when the _sut.Create is called it's thrown an exception, if I remove MockBehavior....
Milton Calderon's user avatar
0 votes
1 answer
50 views

Invoke function for each enumarable item while mapping with Automapper

I have 2 classes: class A { public int MyProperty { get; set; } } class ADto { public int MyProperty { get; set; } public bool Flag { get; set; } } I would like to map IEnumerable to ...
Yoda's user avatar
  • 17.5k
-1 votes
1 answer
54 views

How to map an object inside another object using Automapper?

I'm trying to do the mapping to display a value that is inside an entity, which is inside another entity that is inside another entity, the sequence is "Hose" > "Equipment" > ...
Guilherme Costa's user avatar
-3 votes
1 answer
188 views

AutoMapper error after upgrading to .NET 7

I upgraded a .NET Core 2.1 app to .NET 7 and upgraded the AutoMapper version that was being used to the latest version. I had to change the ResolveUsing calls to MapFrom as the earlier was not ...
Angelo's user avatar
  • 47
-1 votes
1 answer
56 views

How to refactor a AutoMapper function in Net Core

I'm resolving a Software Developer entrance exam where I have to develop a Student Enroll courses app, and in one of the stages wherein it requires to write a Mapper function that map a Model with his ...
Turing's user avatar
  • 23
0 votes
1 answer
68 views

can AutoMapper map to derived/runtime property types from Dictionary<string, object>?

AutoMapper includes support for mapping from a Dictionary<string, object> to an object graph per https://docs.automapper.org/en/stable/Dynamic-and-ExpandoObject-Mapping.html It also has mapping ...
MicrosoftStackDev's user avatar
1 vote
2 answers
90 views

How to make sure that ignoring members in AutoMapper does not set values to null?

I have this code: var variants = CreateMap<TechDataVariant, TechData>(); variants.ForAllMembers(opt => opt.Ignore()); variants.ForPath(dest => dest.Acceleration.Label, opt => opt....
CodingLittle's user avatar
  • 1,817
0 votes
1 answer
52 views

Can't assign null value to a double? property in AutoMapper

I'm using AutoMapper and one line causes an error when I try to assign null in ternary operator like this: .ForMember(dest => dest.VatCategoryTaxAmount, opt => opt.MapFrom(src => ...
lonelydev101's user avatar
  • 1,678
0 votes
1 answer
74 views

How to map a list of object to a DataTable using AutoMapper

This is my current code. public class IncidentMapDatatableProfile : Profile { public IncidentMapDatatableProfile() { CreateMap<FlattenedIncident, DataRow>(); } } public ...
Steve's user avatar
  • 3,433
-2 votes
1 answer
48 views

Send Email To Admin

I need to send a lot of different forms to the mail. For example FeedBackForm ContactsForm. the only difference is that I create different mail.Subject and mail.Body. I need to automate this action. ...
Kirill's user avatar
  • 13

1
2 3 4 5
132