Automapper Many to many mapping #554
wahidrezgui
started this conversation in
General
Replies: 1 comment
-
Have you managed to do this? Or any workarounds available to map multiple classes to same dto |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hy,
Anyone has an idea how to add many to many mapping
I Added two Classes in the domain layer
public class A
{
public int IdA
public ICollection ABs { get; set; }
}
public class B
{
public int IdB
public ICollection ABs { get; set; }
}
public class AB
{
public int IdAB
public int IdA
public int IdB
public A A { get; set; }
public B B { get; set; }
}
and Now in the application layer I want to Create ADtoVm Class
public class ADtoVm : IMapFrom
{
public ADtoVm ()
{
Bs= new List();
}
Now in the mapping Method I'm stacked
public void Mapping(Profile profile)
{
profile.CreateMap<A, ADtoVm >()
.ForMember(......., opt => opt.Ignore())
.ForMember(dto => dto.Bs, opt => opt.MapFrom(x => x.........
I can't figure out how to get the relation Many to many
as a result i want
A {
..... properties
Bs:[{ B1,B2}]
}
as a nested classes
Beta Was this translation helpful? Give feedback.
All reactions