056 Modeling Composite Lookup Resource Entities for PhbkEmployee - chempkovsky/CS82ANGULAR GitHub Wiki
- Lookup dictionary for EmpLastName
- Lookup dictionary for EmpFirstName
- Lookup dictionary for EmpSecondName
- 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:
EmpLastNameEmpFirstNameEmpSecondName
- the end user can define a partial filter
- for one prop:
EmpLastName - for two prop:
EmpLastNameandEmpFirstName
- for one prop:
- 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
- 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
- should have two columns:
- 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)
-
LpdEmpLastNamewill be the name of the dictionary table - According to the requirements 033 the class declaration must be inside of
#if (!NOTMODELING) ... #endif-operator.
Click to show the code
#if (!NOTMODELING)
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!;
public List<LprEmployee01> EmployeeRef01 { get; set; } = null!;
public List<LprEmployee02> EmployeeRef02 { get; set; } = null!;
}
}
#endif-
LpdEmpFirstNamewill be the name of the dictionary table - According to the requirements 033 the class declaration must be inside of
#if (!NOTMODELING) ... #endif-operator.
Click to show the code
#if (!NOTMODELING)
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!;
public List<LprEmployee01> EmployeeRef01 { get; set; } = null!;
public List<LprEmployee02> EmployeeRef02 { get; set; } = null!;
}
}
#endif-
LpdEmpSecondNamewill be the name of the dictionary table - According to the requirements 033 the class declaration must be inside of
#if (!NOTMODELING) ... #endif-operator.
Click to show the code
#if (!NOTMODELING)
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;
public List<LprEmployee01> EmployeeRef01 { get; set; } = null!;
public List<LprEmployee02> EmployeeRef02 { get; set; } = null!;
}
}
#endif-
along-mode is a mode in which the component is not used as detail node in master-detail navigation chain and in which the component is not used as detail panel on theone-to-many-page. -
According to the requirements 033
- lookup refs-table must have the foreign key which references lookup dictionaries
-
lookup refs-table must have the foreign key which references
PhbkEmployee. It is a table for which we are going to create lookup resource
-
LprEmployee01will be the name for the table -
According to the requirements 033 the class declaration must be inside of
#if (!NOTMODELING) ... #endif-operator.
Click to show the code
#if (!NOTMODELING)
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PhBkEntity.PhBk
{
public class LprEmployee01
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Row id", Name = "Id of the Employee", Prompt = "Enter Employee Id", ShortName = "Employee Id")]
[Required]
public int EmployeeId { get; set; }
public PhbkEmployee Employee { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Row ref id", Name = "ref Id of the Row", Prompt = "Enter Row ref Id", ShortName = "Row ref Id")]
[Required]
public int EmpLastNameIdRef { get; set; }
public LpdEmpLastName EmpLastNameDict { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Row ref id", Name = "ref Id of the Row", Prompt = "Enter Row ref Id", ShortName = "Row ref Id")]
[Required]
public int EmpFirstNameIdRef { get; set; }
public LpdEmpFirstName EmpFirstNameDict { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "S name ref id", Name = "Id of the Row", Prompt = "Enter Row Id", ShortName = "Row Id")]
[Required]
public int EmpSecondNameIdRef { get; set; }
public LpdEmpSecondName EmpSecondNameDict { get; set; } = null!;
}
}
#endif-
one-to-many-mode is a mode in which the component is used as detail node in master-detail navigation chain or in which the component is used as detail panel on theone-to-many-page. - According to the requirements 033
- lookup refs-table must have the foreign key which references lookup dictionaries
-
lookup refs-table must have the foreign key which references
PhbkEmployee. It is a table for which we are going to create lookup resource -
lookup refs-table must have the foreign key which references
PhbkDivision-table. This is becausePhbkEmployeereferencesPhbkDivision-table as well.
- According to the requirements 033 the class declaration must be inside of
#if (!NOTMODELING) ... #endif-operator.
Click to show the code
#if (!NOTMODELING)
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PhBkEntity.PhBk
{
public class LprEmployee02
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Emp Row id", Name = "Id of the Employee", Prompt = "Enter Employee Id", ShortName = "Employee Id")]
[Required]
public int EmployeeId { get; set; }
public PhbkEmployee Employee { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Lst name ref id", Name = "Lst name ref Id", Prompt = "Enter Lst name ref Id", ShortName = "Lst name ref Id")]
[Required]
public int EmpLastNameIdRef { get; set; }
public LpdEmpLastName EmpLastNameDict { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Frst name ref id", Name = "Frst name ref Id", Prompt = "Enter Frst name ref Id", ShortName = "Frst name ref Id")]
[Required]
public int EmpFirstNameIdRef { get; set; }
public LpdEmpFirstName EmpFirstNameDict { get; set; } = null!;
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Sec name ref id", Name = "Sec name ref Id", Prompt = "Enter Sec name ref Id", ShortName = "Sec name ref Id")]
[Required]
public int EmpSecondNameIdRef { get; set; }
public LpdEmpSecondName EmpSecondNameDict { get; set; } = null!;
[Display(Description = "Division Row id", Name = "Id of the Division", Prompt = "Enter Division Id", ShortName = "Division Id")]
[Required]
public int DivisionIdRef { get; set; }
public PhbkDivision Division { get; set; } = null!;
}
}
#endif-
LprEmployee01andLprEmployee02referencesPhbkEmployee-table. To accomplish the foreign key declaration we need to add inverse reference in thePhbkEmployee-table. - According to the requirements 033 the inverse reference code must be inside of
#if (!NOTMODELING) ... #endif-operator. - Here is a new version
PhbkEmployee-table.
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PhBkEntity.PhBk
{
public class PhbkEmployee
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Description = "Row id", Name = "Id of the Employee", Prompt = "Enter Employee Id", ShortName = "Employee Id")]
[Required]
public int EmployeeId { 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!;
[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!;
[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; }
[Display(Description = "Row id", Name = "Id of the Division", Prompt = "Enter Division Id", ShortName = "Division Id")]
[Required]
public int DivisionIdRef { get; set; }
public PhbkDivision Division { get; set; } = null!;
#if (!NOTMODELING)
public List<LprEmployee01> EmployeeRefs01 { get; set; } = null!;
public List<LprEmployee02> EmployeeRefs02 { get; set; } = null!;
#endif
}
}-
LprEmployee02referencesPhbkDivision-table. To accomplish the foreign key declaration we need to add inverse reference in thePhbkDivision-table. - According to the requirements 033 the inverse reference code must be inside of
#if (!NOTMODELING) ... #endif-operator. - Here is a new version
PhbkDivision-table.
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PhBkEntity.PhBk
{
public class PhbkDivision
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Description = "Row id", Name = "Id of the Division", Prompt = "Enter Division Id", ShortName = "Division Id")]
[Required]
public int DivisionId { get; set; }
[Display(Description = "Name of the Enterprise Division", Name = "Name of the Division", Prompt = "Enter Division Name", ShortName = "Division Name")]
[StringLength(20, MinimumLength = 3, ErrorMessage = "Invalid")]
[Required]
public string DivisionName { get; set; } = null!;
[Display(Description = "Description of the Enterprise Division", Name = "Description of the Division", Prompt = "Enter Enterprise Division Description", ShortName = "Division Description")]
[StringLength(250, ErrorMessage = "Invalid")]
public string? DivisionDesc { get; set; }
[Display(Description = "Row id", Name = "Id of the Enterprise", Prompt = "Enter Enterprise Id", ShortName = "Enterprise Id")]
[Required]
public int EntrprsIdRef { get; set; }
public PhbkEnterprise Enterprise { get; set; } = null!;
public List<PhbkEmployee> Employees { get; set; } = null!;
#if (!NOTMODELING)
public List<LprDivision01> DivisionRefs01 { get; set; } = null!;
public List<LprDivision02> DivisionRefs02 { get; set; } = null!;
public List<LprEmployee02> EmployeeRefs02 { get; set; } = null!;
#endif
}
}