π LytxTemplate Class Documentation
Welcome to the comprehensive documentation for the LytxTemplate domain class from the IrbyImaging.DomainClasses assembly. This guide covers everything you need to know to understand, use, and extend the LytxTemplate model in your .NET application.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Data Model & Entity Definition
- Properties Breakdown
- Entity Framework Mapping
- UML Class Diagram
- Usage Examples & Code Snippets
- Conclusion
π Overview & Purpose
LytxTemplate is a simple Plain Old CLR Object (POCO) that represents a database table named irby.LytxTemplate. It is used to store and retrieve vehicle/driver shift details processed in batches. This model is designed for use with Entity Framework Core and sits in the IrbyImaging.DomainClasses project, which contains all the core domain entities for the Irby Imaging system.
Key Responsibilities:
- Map C# properties to database columns.
- Serve as the domain representation of a Lytx data processing record.
- Provide a typed structure for CRUD operations in the repository layer.
π Dependencies & Technologies
| Technology | Version/Notes |
|---|---|
| .NET | .NET 5 / .NET Core 3.1 |
| Entity Framework Core | For ORM and table mappings |
| System.ComponentModel.DataAnnotations | Attributes for validation & schema |
| System.ComponentModel.DataAnnotations.Schema | Schema/table binding |
Namespace:
namespace IrbyImaging.DomainClasses
π¦ Data Model & Entity Definition
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IrbyImaging.DomainClasses
{
/// <summary>
/// Represents a Lytx shift processing template.
/// </summary>
[Table("LytxTemplate", Schema = "irby")]
public class LytxTemplate
{
[Key]
public Guid Id { get; set; }
public string VehicleId { get; set; }
public string DriverId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string ShiftStart { get; set; }
public string ShiftEnd { get; set; }
public DateTime ProcessingDate { get; set; }
public Guid BatchId { get; set; }
}
}
π Properties Breakdown
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Primary key. Uniquely identifies each record. |
| VehicleId | string |
Identifier for the vehicle. |
| DriverId | string |
Identifier for the driver. |
| FirstName | string |
Driverβs first name. |
| LastName | string |
Driverβs last name. |
| ShiftStart | string |
Shift start timestamp (ISO 8601 string recommended). |
| ShiftEnd | string |
Shift end timestamp (ISO 8601 string recommended). |
| ProcessingDate | DateTime |
Date when the shift data was processed. |
| BatchId | Guid |
Foreign key linking to a batch record for grouping multiple LytxTemplate entries. |
π Entity Framework Mapping
- Table:
irby.LytxTemplate - Schema:
irby - Primary Key:
Id - Column Conventions: Default EF Core conventions apply for string-to-varchar mapping; adjust in
DbContext.OnModelCreatingif needed.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<LytxTemplate>()
.ToTable("LytxTemplate", schema: "irby")
.HasKey(l => l.Id);
// Optional: configure column lengths, types, etc.
modelBuilder.Entity<LytxTemplate>()
.Property(l => l.VehicleId)
.HasMaxLength(50)
.IsRequired();
}
πΊ UML Class Diagram
classDiagram
class LytxTemplate {
+Guid Id
+string VehicleId
+string DriverId
+string FirstName
+string LastName
+string ShiftStart
+string ShiftEnd
+DateTime ProcessingDate
+Guid BatchId
}
π» Usage Examples & Code Snippets
1. Adding a New Record
using var context = new IrbyDbContext();
var template = new LytxTemplate
{
Id = Guid.NewGuid(),
VehicleId = "VHC12345",
DriverId = "DRVR67890",
FirstName = "John",
LastName = "Doe",
ShiftStart = "2022-07-01T08:00:00Z",
ShiftEnd = "2022-07-01T16:00:00Z",
ProcessingDate = DateTime.UtcNow,
BatchId = existingBatchId
};
context.LytxTemplates.Add(template);
context.SaveChanges();
2. Querying Records by Batch
using var context = new IrbyDbContext();
var batchEntries = context.LytxTemplates
.Where(l => l.BatchId == targetBatchId)
.OrderBy(l => l.ProcessingDate)
.ToList();
3. Updating a Shift End
var record = context.LytxTemplates.Find(recordId);
if (record != null)
{
record.ShiftEnd = DateTime.UtcNow.ToString("o");
context.SaveChanges();
}
β Conclusion
The LytxTemplate class is a foundational domain entity for capturing and persisting Lytx shift data within the Irby Imaging system. By following EF Core conventions and simple POCO design, it ensures easy integration, maintainability, and testability.
π Next Steps
- Integrate with repository and service layers for business logic.
- Add Fluent API or Data Annotations for stricter validation/column constraints.
- Write unit tests to ensure mapping and CRUD operations function as expected.
Thank you for reading! If you have any questions or need further assistance, feel free to reach out to the Irby Imaging development team. π
Enjoy coding!