Skip to content

Commit

Permalink
refactor: Remove mapeamento com DataAnnotations
Browse files Browse the repository at this point in the history
  • Loading branch information
renebentes committed Oct 6, 2022
1 parent 7831b15 commit 4e2d2a4
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 25 deletions.
12 changes: 0 additions & 12 deletions Blog/Models/Category.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Blog.Models;

[Table(nameof(Category))]
public class Category : ModelBase
{
[Required]
[MinLength(3)]
[MaxLength(80)]
[Column(nameof(Slug), TypeName = "VARCHAR")]
public string Slug { get; set; } = string.Empty;

[Required]
[MinLength(3)]
[MaxLength(80)]
[Column(nameof(Title), TypeName = "NVARCHAR")]
public string Title { get; set; } = string.Empty;
}
5 changes: 0 additions & 5 deletions Blog/Models/ModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Blog.Models;

public abstract class ModelBase
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
}
5 changes: 0 additions & 5 deletions Blog/Models/Post.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace Blog.Models;

[Table(nameof(Post))]
public class Post : ModelBase
{
public User Author { get; set; } = new();

[ForeignKey(nameof(AuthorId))]
public int AuthorId { get; set; }

public string Body { get; set; } = string.Empty;

public Category Category { get; set; } = new();

[ForeignKey(nameof(CategoryId))]
public int CategoryId { get; set; }

public DateTime CreateDate { get; set; }
Expand Down
3 changes: 0 additions & 3 deletions Blog/Models/Tag.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace Blog.Models;

[Table("Tag")]
public class Tag : ModelBase
{
public string Name { get; set; } = string.Empty;
Expand Down

0 comments on commit 4e2d2a4

Please sign in to comment.