Note Onion - Domain - NoteEntity

Here is the source code for NoteEntity.cs file it is placed in the Entities directory of the Note.Domain project.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace Note.Domain.Entities
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class NoteEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }

public DateTime Dt { get; set; }

[StringLength(40)]
public string Who { get; set; }

[Required]
//[ForeignKey("NoteType")]
// https://stackoverflow.com/questions/5542864/how-should-i-declare-foreign-key-relationships-using-code-first-entity-framework
// This will be recognized as FK by NavigationPropertyNameForeignKeyDiscoveryConvention
//[ForeignKey("NoteTypeEntity")]
public long NoteTypeId { get; set; }
public virtual NoteTypeEntity NoteTypeEntity { get; set; }

[Column(TypeName = "nvarchar(max)")]
public string Note { get; set; }

[StringLength(255)]
public string CompanyKey { get; set; }

[StringLength(255)]
public string ApplicationSubKey { get; set; }

[StringLength(255)]
public string ApplicationKey { get; set; }
}
}

A couple of notes.

  • Compared to the Telerik article, these attributes have annotations which help define the validity of the data. I have included 2 using systements to help support this feature.
  • The ApplicationKey, and ApplicationSubKey columns are intended to help differentiate the notes for different applications in a company. For example the company might have a GL and a DD application. GL might have AR, and AP objects which depend on notes. So maybe we would have an applicationKey of “GL-AR”, and for objects 1 through 4, we would have applicationSubKeys of 1 through 2.