You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WF-PmAPI/WF_EF_Api/Entity/Quote.cs

54 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Quote
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[StringLength(100)]
public string Content { get; set; }
[Required]
public int Likes { get; set; }
[Required]
public LangEnum Langage { get; set; }
[Required]
public bool IsValid { get; set; }
[Required]
[ForeignKey(nameof(Character))]
public int IdCharacter { get; set; }
[Required]
[ForeignKey(nameof(Source))]
public int IdSource { get; set; }
[ForeignKey(nameof(Users))]
public int? IdUsersPropose { get; set; }
//Réson de pour quoi j'ai mis le user en nullable et mis .OnDelete(DeleteBehavior.ClientSetNull) dans WTFContext
//https://learn.microsoft.com/fr-fr/ef/core/saving/cascade-delete
//Les suppressions en cascade sont nécessaires quand une entité dépendante/enfant ne peut plus être associée à son entité principale/parente actuelle. Cela peut se produire à la suite de la suppression de lentité principale/parente, ou quand lentité principale/parente existe toujours mais que lentité dépendante/enfant ne lui est plus associée.
public Users? User { get; set; } = null!;
public Source Source { get; set; } = null!;
public Character Character { get; set; } = null!;
public ICollection<Commentary> Commentarys { get; set; } = new List<Commentary>();
public ICollection<Users> Favorite { get; } = new List<Users>();
}
}