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
{{ message }}
Repository navigation
Mapping class to record result in empty properties #338
When mapping to record, Mapster will map to constructor parameter. Your parameter name has _ prefix. Either config naming convention or rename your parameter.
When mapping to record, Mapster will map to constructor parameter. Your parameter name has _ prefix. Either config naming convention or rename your parameter.
Hi,
Yes, you're right.
looking better, i found the condition
this classes mapped correctly :
public class DAO
{
public string? Name { get; set; }
public string? Code{ get; set; }
}
public record DTO
(
string? Name,
string? Code
);
If I change the name of the property 'Code' in 'CodeEU', this property isn't mapped.
public class DAO
{
public string? Name { get; set; }
public string? CodeEU{ get; set; }
}
public record DTO
(
string? Name,
string? CodeEU
);
I faced the same issue:
this record
public record CreateItemCommand
(
int userId,
int sourceId,
string note
)
BUT When I' capitalized all properties it's working perfectly
public record CreateItemCommand
(
int UserId,
int SourceId,
string Note
)
Activity
chaowlert commentedon May 17, 2021
When mapping to record, Mapster will map to constructor parameter. Your parameter name has
_prefix. Either config naming convention or rename your parameter.mcamorchia commentedon May 17, 2021
Hi,
Yes, you're right.
looking better, i found the condition
this classes mapped correctly :
If I change the name of the property 'Code' in 'CodeEU', this property isn't mapped.
chaowlert commentedon May 17, 2021
Oh, this could be bug
jods4 commentedon Jul 29, 2021
I believe I'm seeing the same issue here.
Mapping to this class works:
But if I try to shorten the code and map to a C# 9.0 record, it doesn't work anymore:
When I map to the record,
Idis correctly mapped, butNAMEis ignored.It stays
nulland is completely absent from theProjectToexpression.hechengyuhui commentedon Oct 4, 2021
I'm also seeing the same issue.
Maybe the consecutive uppercase letters caused this bug.
When I map to the record like this:
public record DTO(string PlatformName, string URL);PlatformName is correctly mapped while URL stays null.
But this record can be mapped correctly:
public record DTO(string PlatformName, string Url);andrerav commentedon Feb 19, 2022
Possibly related to #388.
wahidrezgui commentedon Mar 21, 2023
I faced the same issue:
this record
public record CreateItemCommand
(
int userId,
int sourceId,
string note
)
BUT When I' capitalized all properties it's working perfectly
public record CreateItemCommand
(
int UserId,
int SourceId,
string Note
)
andrerav commentedon May 29, 2023
Fixed in #590