Skip to content

056 Modeling Composite Lookup Resource Entities for PhbkEmployee

chempkovsky edited this page May 30, 2022 · 6 revisions

Notes

  • We say that a Lookup Resource is Composite if it has more than one search property.
  • We are going to create a lookup resource for three scalar properties:
    • EmpLastName
    • EmpFirstName
    • EmpSecondName
  • the end user can define a partial filter
    • for one prop: EmpLastName
    • for two prop: EmpLastName and EmpFirstName
  • According to the requirements 033 we need to create three lookup dictionary-table and two lookup refs-table. (The number of the lookup refs-tables depends on the number of the foreign keys)
  • each dictionary table table
    • should have two columns:
      • row id column with a primary key on it
      • data column with a unique key on it
      • the name of the data column must be the same as column name of the PhbkEmployee-table
  • Naming prefix for the lookup dictionary-tables will be Lpd (which means lookup dictionary)
  • Naming prefix for the lookup refs-tables will be Lpr (which means lookup refs)

Lookup dictionaries

Lookup dictionary for EmpLastName

  • LpdEmpLastName will be the name of the dictionary table
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PhBkEntity.PhBk
{
    public class LpdEmpLastName
    {

        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Description = "Row id", Name = "Id of the Row", Prompt = "Enter Row Id", ShortName = "Row Id")]
        [Required]
        public int EmpLastNameId { get; set; }

        [Display(Description = "Last Name of the Employee", Name = "Employee Last Name", Prompt = "Enter Employee Last Name", ShortName = "Last Name")]
        [StringLength(40, MinimumLength = 3, ErrorMessage = "Invalid")]
        [Required]
        public string EmpLastName { get; set; } = null!;

    }
}

Lookup dictionary for EmpFirstName

  • LpdEmpFirstName will be the name of the dictionary table
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PhBkEntity.PhBk
{
    public class LpdEmpFirstName
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Description = "Row id", Name = "Id of the Row", Prompt = "Enter Row Id", ShortName = "Row Id")]
        [Required]
        public int EmpFirstNameId { get; set; }

        [Display(Description = "First Name of the Employee", Name = "Employee First Name", Prompt = "Enter Employee First Name", ShortName = "First Name")]
        [StringLength(25, MinimumLength = 3, ErrorMessage = "Invalid")]
        [Required]
        public string EmpFirstName { get; set; } = null!;
    }
}

Lookup dictionary for EmpSecondName

  • LpdEmpSecondName will be the name of the dictionary table
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PhBkEntity.PhBk
{
    public class LpdEmpSecondName
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Description = "Row id", Name = "Id of the Row", Prompt = "Enter Row Id", ShortName = "Row Id")]
        [Required]
        public int EmpSecondNameId { get; set; }

        [Display(Description = "Row id", Name = "Employee Second Name", Prompt = "Enter Employee Second Name", ShortName = "Second Name")]
        [StringLength(25, ErrorMessage = "Invalid")]
        public string EmpSecondName { get; set; } = string.Empty;
    }
}
Clone this wiki locally