Соответствует части двух моделей...
Код: Выделить всё
public class User {
public UserRole Role { get; set; }
public int? CompanyId { get; set; }
public virtual Company? Company { get; set; }
}
public class Company {
public virtual ObservableCollection Users { get; set; } = [];
}
Код: Выделить всё
public class UserDto {
public int? CompanyId { get; set; }
public string CompanyName { get; set; } = "";
}
public record CompanyOverviewDto(int Id, bool Active, string Name);
public class CompanyDto {
public List Users { get; set; } = [];
}
Код: Выделить всё
public class AutoMapperProfile : Profile {
public AutoMapperProfile() {
CreateMap();
CreateMap().ReverseMap();
CreateMap()
.ReverseMap();
}
}
Как я могу остановить это? Если CompanyId имеет значение null, я не хочу, чтобы AutoMapper добавлял пустую компанию.
Подробнее здесь: https://stackoverflow.com/questions/792 ... id-is-null