Employee
Example model for ECRUD.
Class documentation
This example uses Oracle HR schema.
Code
Column representation, one-to-one, one-to-many relationships, and all specifications for mapping a table.
#region Employee
[Serializable]
[ECRUD.NoteSchema("HR")]
[ECRUD.NoteTable("EMPLOYEES")]
[ECRUD.PrimaryKey("EMPLOYEE_ID", SequenceType = ECRUD.Enums.SequenceType.Name, SequenceName = "EMPLOYEES_SEQ")]
public class Employee
{
public Employee()
{
JobHistory = new List();
}
//Column
[ECRUD.Column("EMPLOYEE_ID")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.NUMBER)]
public long? EmployeeId { get; set; }
//Column
[ECRUD.Column("FIRST_NAME")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.VARCHAR2)]
public string FirstName { get; set; }
//Column
[ECRUD.Column("LAST_NAME")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.VARCHAR2)]
public string LastName { get; set; }
//Column
[ECRUD.Column("EMAIL")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.VARCHAR2)]
public string Email { get; set; }
//Column
[ECRUD.Column("PHONE_NUMBER")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.VARCHAR2)]
public string PhoneNumber { get; set; }
//Column
[ECRUD.Column("HIRE_DATE")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.DATE)]
public DateTime? HireDate { get; set; }
//Column
[ECRUD.Column("SALARY")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.NUMBER)]
public long? Salary { get; set; }
//Column
[ECRUD.Column("COMMISSION_PCT")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.NUMBERSCALE)]
public double? CommissionPct { get; set; }
//Column
[ECRUD.Column("JOB_ID")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.VARCHAR2)]
public string JobId { get; set; }
//Column
[ECRUD.Column("DEPARTMENT_ID")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.NUMBER)]
public long? DepartmentId { get; set; }
//Column
[ECRUD.Column("PHOTO")]
[ECRUD.NoteDataType(ECRUD.Enums.DataTypes.BLOB)]
public byte[] Photo { get; set; }
//One to one mapping
[ECRUD.OneToOne("JOBS", "JOB_ID", "JOB_ID")]
public Job Job { get; set; }
//One to one mapping
[ECRUD.OneToOne("DEPARTMENTS", "DEPARTMENT_ID", "DEPARTMENT_ID")]
public Department Department { get; set; }
//One to many mapping
[ECRUD.OneToMany("JOB_HISTORY", "EMPLOYEE_ID", "EMPLOYEE_ID")]
public List<JobHistory> JobHistory { get; set; }
}
#endregion