You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using Mapster;
using MapsterMapper;
var foo = new Foo(1, 2);
var t = foo.Get();
// var bar = t.Adapt<Bar>(); // <== Failed: '<>f__AnonymousType0<int,int>' does not contain a definition for 'Adapt'
// var bar = t.BuildAdapter().AdaptToType<Bar>(); // <== Failed '<>f__AnonymousType0<int,int>' does not contain a definition for 'BuildAdapter'
var mapper = new Mapper(TypeAdapterConfig.GlobalSettings);
var bar = mapper.Map<Bar>(t); // <== OK
// var t = new { A = 1, B = 2 };
// var bar = t.Adapt<Bar>(); // <== Failed: '<>f__AnonymousType0<int,int>' does not contain a definition for 'Adapt'
// var bar = t.BuildAdapter().AdaptToType<Bar>(); // <== OK
Console.WriteLine($"A = {bar.A}; B = {bar.B}");
public class Foo
{
private int a;
private int b;
public Foo(int a, int b)
{
this.a = a;
this.b = b;
}
public dynamic Get()
{
return new { A = a, B = b };
}
}
public class Bar
{
public int A { get; set; }
public int B { get; set; }
}
But IMapper works. Why?
The text was updated successfully, but these errors were encountered:
But IMapper works. Why?
The text was updated successfully, but these errors were encountered: