Код: Выделить всё
.ProjectTo(
_mapper.ConfigurationProvider,
new { ndtId = query.NdtId })
Невозможно создать выражение карты из . (Ces.Caspian.Domain.Entities.Piping.LineJoints.LineJoint) в String.NdtType (System.String) Типы сопоставления: LineJoint -> LineJointForNdtSelection Ces.Caspian.Domain.Entities.Piping.LineJoints.LineJoint -> Ces.Caspian.Models.Output.Piping.LineJoints.LineJointForNdtSelection Тип конфигурации карты: LineJoint -> LineJointForNdtSelection Ces.Caspian.Domain.Entities.Piping.LineJoints.LineJoint -> Ces.Caspian.Models.Output.Piping.LineJoints.LineJointForNdtSelection Элемент назначения: NdtType.
Родительская таблица:
Код: Выделить всё
public class LineJoint : EntityBase
{
public const int JointNoIndexMaxLength = 5;
public const int JointNoMaxLength = 20;
public LineJoint()
{
}
public LineJoint(Guid? userId) : base(userId)
{
}
public Guid? ContractorId { get; set; }
public Guid? LineSheetId { get; set; }
public string? JointNo { get; set; }
public Guid? ScheduleId { get; set; }
public Guid? ConnectionTypeId { get; set; }
public Guid? EndStatusId { get; set; }
public Guid? EndTypeId { get; set; }
public Guid? JointTypeId { get; set; }
public Guid? LocationId { get; set; }
public Guid? WeldTypeId { get; set; }
public int Revision { get; set; }
public Guid? TestPackageId { get; set; }
// Navigation
public Domain.Entities.Project.Contractors.Contractor? Contractor { get; set; }
public Domain.Entities.Piping.LineSheets.LineSheet? LineSheet { get; set; }
public Domain.Entities.Piping.ConnectionTypes.ConnectionType? ConnectionType { get; set; }
public Domain.Entities.Piping.EndTypes.EndType? EndType { get; set; }
public Domain.Entities.Piping.EndStatuses.EndStatus? EndStatus { get; set; }
public Domain.Entities.Piping.JointTypes.JointType? JointType { get; set; }
public Domain.Entities.Piping.Locations.Location? Location { get; set; }
public Domain.Entities.Piping.WeldTypes.WeldType? WeldType { get; set; }
public Domain.Entities.TestPackage.TestPackages.TestPackage? TestPackage { get; set; }
public Domain.Entities.Piping.Schedules.Schedule? Schedule { get; set; }
public List? NdtStatuses { get; set; }
}
Код: Выделить всё
public class NdtStatus : Entities.EntityBase
{
public const int NDTNoMaxLength = 50;
public NdtStatus()
{
}
public NdtStatus(Guid? userId) : base(userId)
{
}
public Guid? LineJointId { get; set; }
public Guid? NdtId { get; set; }
public bool Required { get; set; }
public bool Exempted { get; set; }
public string? NdtNo { get; set; }
public Guid? NdtTypeId { get; set; }
// Navigation
public Domain.Entities.Piping.LineJoints.LineJoint? LineJoint { get; set; }
public Domain.Entities.Piping.Ndts.Ndt? Ndt { get; set; }
public Domain.Entities.Piping.NdtTypes.NdtType? NdtType { get; set; }
}
Код: Выделить всё
public class LineJointForNdtSelection : OutputModelEssentials
{
// From parent table
public Guid JointId { get; set; }
public string? Contractor { get; set; }
public string? SheetNo { get; set; }
public string? JointNo { get; set; }
public string? ConnectionType { get; set; }
public string? EndStatus { get; set; }
public string? EndType { get; set; }
public string? JointType { get; set; }
public string? Location { get; set; }
public string? PackageNo { get; set; }
// From child table
public string? Ndt { get; set; }
public string? NdtType { get; set; }
public bool Required { get; set; }
public bool Exempted { get; set; }
public string? NdtNo { get; set; }
public string? RequestNo { get; set; }
public string? ReportNo { get; set; }
public string? Result { get; set; }
}
Код: Выделить всё
public class LineJointForNdtSelection : AutoMapper.Profile
{
public LineJointForNdtSelection()
{
CreateMap<
Domain.Entities.Piping.LineJoints.LineJoint,
Models.Output.Piping.LineJoints.LineJointForNdtSelection>()
// From parent table
.ForMember(x => x.JointId, x => x.MapFrom(x => x.Id))
.ForMember(x => x.Contractor, x => x.MapFrom(x => x.Contractor.Name))
.ForMember(x => x.SheetNo, x => x.MapFrom(x => x.LineSheet.SheetNo))
.ForMember(x => x.ConnectionType, x => x.MapFrom(x => x.ConnectionType.Name))
.ForMember(x => x.EndStatus, x => x.MapFrom(x => x.EndStatus.Name))
.ForMember(x => x.EndType, x => x.MapFrom(x => x.EndType.Name))
.ForMember(x => x.JointType, x => x.MapFrom(x => x.JointType.Name))
.ForMember(x => x.Location, x => x.MapFrom(x => x.Location.Name))
.ForMember(x => x.PackageNo, x => x.MapFrom(x => x.TestPackage.TestPackageNo))
// From child table
.ForMember(x => x.NdtType, opt => opt.MapFrom((src, dest, destMember, context)
=> new Profiles.Piping.NdtStatuses.Resolvers.NdtTypeResolver((Guid)context.Items["ndtId"])
.Resolve(src, dest, destMember, context)));
;
}
}
Код: Выделить всё
public class NdtTypeResolver : IValueResolver<
Ces.Caspian.Domain.Entities.Piping.LineJoints.LineJoint,
Ces.Caspian.Models.Output.Piping.LineJoints.LineJointForNdtSelection,
string?>
{
private Guid? _ndtId;
public NdtTypeResolver()
{
}
public NdtTypeResolver(Guid? ndtId = null)
{
_ndtId = ndtId;
}
public string? Resolve(
Ces.Caspian.Domain.Entities.Piping.LineJoints.LineJoint source,
Ces.Caspian.Models.Output.Piping.LineJoints.LineJointForNdtSelection destination,
string? destMember,
ResolutionContext context)
{
return source.NdtStatuses?.FirstOrDefault(c
=> c.LineJointId == source.Id && c.NdtId == _ndtId)?.NdtType?.Name ?? string.Empty;
}
}
Код: Выделить всё
public async Task GetLineJointsForNdtSelectionAsync(
Models.Input.Queries.Piping.LineJoints.GetLineJointsForNdtSelection query)
{
var result = await _dbContext.LineJoints
.Where(x => x.LineSheet.LineNumberId == query.LineNumberId)
.ProjectTo(
_mapper.ConfigurationProvider,
new { ndtId = query.NdtId })
.AsNoTracking()
.ToListAsync()
;
return result;
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... er-profile
Мобильная версия