Answer the question
In order to leave comments, you need to log in
EF Core, how to properly drag the required fields?
Good day.
There is a base like this:
public class BaseIdEntity
{
public int Id { get; set; }
public bool IsDeleted { get; set; }
}
//Основной класс, с которым и производится вся работа.
public class MAOrder : BaseIdEntity
{
public DateTime DateStart { get; set; }
public DateTime? DateEnd { get; set; }
public DateTime? DateComplete { get; set; }
public DateTime? PaymentDate { get; set; }
public bool IsPaid { get; set; }
public decimal Amount { get; set; }
public MACounterparty? Counterparty { get; set; }
public int? CounterpartyId { get; set; }
public MAOrderStatus? Status { get; set; }
public int? StatusId { get; set; }
public MAPaymentType? PaymentType { get; set; }
public int? PaymentTypeId { get; set; }
public ApplicationUser? Creator { get; set; }
public string? CreatorId { get; set; }
public ApplicationUser? Worker { get; set; }
public string? WorkerId { get; set; }
public ICollection<MAOrderPosition> Positions { get; set; } //позиции заказа
}
public class MACounterparty : BaseIdEntity
{
public CounterpartyCategory Category { get; set; }
[MARequired]
public string Name { get; set; }
[MARequired]
public string Telephone { get; set; }
[EmailAddress]
public string? EMail { get; set; }
public string? Comment { get; set; }
public ICollection<MAOrder> Orders { get; set; }
}
public class MAOrderPosition : BaseIdEntity
{
public DateTime DateStart { get; set; }
public DateTime? DateEnd { get; set; }
public DateTime? DateComplete { get; set; }
[MARequired]
[MAMaxLength(150)]
public string Description { get; set; }
[MAMaxLength(150)]
public string? Comment { get; set; }
public decimal Cost { get; set; }
public decimal CostPrice { get; set; }
public int Count { get; set; }
public bool IsReOrder { get; set; }
public MAOrder? Order { get; set; }
public int? OrderId { get; set; }
public MAOrderStatus? Status { get; set; }
public int? StatusId { get; set; }
public MAOrderCategory? Category { get; set; }
public int? CategoryId { get; set; }
}
public class NameColor : BaseIdEntity
{
[MARequired]
public string Name { get; set; }
[MARequired]
public string Color { get; set; }
}
public class MAOrderCategory : NameColor
{
public ICollection<MAOrderPosition> Positions { get; set; }
}
public class MAOrderStatus : NameColor
{
public ICollection<MAOrder> Orders { get; set; }
public ICollection<MAOrderPosition> Positions { get; set; }
}
public class MAPaymentType : BaseIdEntity
{
public string Name { get; set; }
public ICollection<MAOrder> Orders { get; set; }
}
Answer the question
In order to leave comments, you need to log in
Select/ Automapper / Mapster . There are no more options.
I would argue about the amount of code - in the case of Select, no one forbids reusing already written code if it is used in many places.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question