- Fri Mar 11, 2016 11:05 am
#4781
Hello,
i have few questions about entities design, suppose we have these 2 classes
1 - It's right use the [Required] attribute on the PartnerType property of the Partner class?
2 - Whenever there is a relation between class, i must use the ForeignKey attributes?
3 - With the [Required] attribute on the PartnerType property of the Partner class i have a issue trying deleting a Partner, below the code
The delete (indeed soft delete) fail reporting this validation error: "The PartnerType field is required". Why?
Thanks in advance,
Diego
i have few questions about entities design, suppose we have these 2 classes
Code: Select all
public class Partner : FullAuditedEntity, IPassivable, IMayHaveTenant
{
public const int MaxNameLength = 100;
[Required]
[StringLength(MaxNameLength)]
public virtual string Name { get; set; }
[Required]
public virtual PartnerType PartnerType { get; set; }
public virtual int? TenantId { get; set; }
public virtual bool IsActive { get; set; }
}
public class PartnerType : Entity, IPassivable, IMayHaveTenant
{
public const int MaxNameLength = 100;
[Required]
[StringLength(MaxNameLength)]
public virtual string Name { get; set; }
public virtual int? TenantId { get; set; }
public virtual bool IsActive { get; set; }
}
1 - It's right use the [Required] attribute on the PartnerType property of the Partner class?
2 - Whenever there is a relation between class, i must use the ForeignKey attributes?
3 - With the [Required] attribute on the PartnerType property of the Partner class i have a issue trying deleting a Partner, below the code
Code: Select all
public async Task DeletePartner(IdInput input)
{
await _partnersRepository.DeleteAsync(input.Id);
}
The delete (indeed soft delete) fail reporting this validation error: "The PartnerType field is required". Why?
Thanks in advance,
Diego