📘 EquipmentType Class Documentation

Welcome to the detailed documentation for the EquipmentType domain class in the IrbyImaging project. This document covers everything from the purpose of the class to sample code usage, including dependencies, properties breakdown, relationships, and a UML sketch.


📑 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Class Definition & Attributes
  4. Properties Breakdown
  5. Entity Relationships
  6. UML Class Diagram
  7. Sample Usage & Code Snippets
  8. Conclusion

1. Overview & Purpose

📌 What is EquipmentType?
EquipmentType is a domain entity representing types of equipment in the Irby Imaging system. It is mapped via Entity Framework to the irby.EquipmentType table in the database.

🎯 Main Responsibilities

  • Uniquely identify each equipment type (EquipmentTypeId)
  • Store a human-readable Name and an integer TypeId code
  • Optionally link to an EquipmentClass for classification

This entity is primarily used in business logic and data access layers to categorize and retrieve equipment information.


2. Dependencies & Technologies

Dependency Purpose
System.ComponentModel.DataAnnotations Data annotations for key, foreign key, and table mapping
System.ComponentModel.DataAnnotations.Schema Schema and table configuration
System Basic CLR types (Guid, etc.)
Entity Framework (via annotations) ORM for mapping this class to a relational database table

3. Class Definition & Attributes

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IrbyImaging.DomainClasses
{
    [Table("EquipmentType", Schema = "irby")]
    public class EquipmentType
    {
        [Key]
        public Guid EquipmentTypeId { get; set; }

        public int TypeId { get; set; }

        public string Name { get; set; }

        public Guid? EquipmentClassId { get; set; }

        [ForeignKey("EquipmentClassId")]
        public EquipmentClass EquipmentClass { get; set; }
    }
}

Key Attributes

  • [Table("EquipmentType", Schema = "irby")]
    – Maps the class to the irby.EquipmentType table.
  • [Key]
    – Marks EquipmentTypeId as the primary key.
  • [ForeignKey("EquipmentClassId")]
    – Configures the navigation property EquipmentClass.

4. Properties Breakdown

Property Type Description
EquipmentTypeId Guid 🔑 Primary Key – globally unique identifier for each EquipmentType.
TypeId int Code or numeric identifier representing the equipment type in business logic.
Name string Human-readable name of the equipment type (e.g., "MRI Scanner", "X-Ray").
EquipmentClassId Guid? Optional FK linking to an EquipmentClass (nullable if unclassified).
EquipmentClass class Navigation property to the parent EquipmentClass entity.

Note: Name has no explicit [Required] attribute, so it may accept null unless constrained by database schema.


5. Entity Relationships

  • EquipmentType (1) —— (0..*) EquipmentClass
    An equipment type may be assigned to one equipment class, grouping similar types.

Relationship Summary

  • EquipmentType.EquipmentClassId → FK column
  • EquipmentType.EquipmentClass → Navigation to parent

6. UML Class Diagram

┌────────────────────────┐
│     EquipmentType      │
├────────────────────────┤
│ - EquipmentTypeId : Guid  ◀── PK
│ - TypeId          : int
│ - Name            : string
│ - EquipmentClassId: Guid?     ◀── FK
├────────────────────────┤
│ + EquipmentClass : EquipmentClass
└────────────────────────┘

7. Sample Usage & Code Snippets

Below are some common scenarios illustrating how to work with the EquipmentType entity using Entity Framework.

7.1 Creating a New EquipmentType

using (var context = new ImagingDbContext())
{
    var newType = new EquipmentType
    {
        EquipmentTypeId = Guid.NewGuid(),
        TypeId = 101,
        Name = "Ultrasound Machine",
        EquipmentClassId = existingClassId  // optional
    };

    context.EquipmentTypes.Add(newType);
    context.SaveChanges();
}

7.2 Querying EquipmentTypes

using (var context = new ImagingDbContext())
{
    // Fetch by TypeId
    var ctScanner = context.EquipmentTypes
                           .FirstOrDefault(et => et.TypeId == 202);
    
    // Include related EquipmentClass
    var allTypesWithClass = context.EquipmentTypes
                                   .Include(et => et.EquipmentClass)
                                   .ToList();
}

7.3 Updating an EquipmentType

using (var context = new ImagingDbContext())
{
    var item = context.EquipmentTypes.Find(targetGuid);
    if (item != null)
    {
        item.Name = "3D CT Scanner";
        context.SaveChanges();
    }
}

7.4 Deleting an EquipmentType

using (var context = new ImagingDbContext())
{
    var toRemove = context.EquipmentTypes.Find(targetGuid);
    if (toRemove != null)
    {
        context.EquipmentTypes.Remove(toRemove);
        context.SaveChanges();
    }
}

8. Conclusion

📌 EquipmentType is a straightforward domain entity designed to classify and store metadata about different kinds of imaging equipment. Mapped to the irby.EquipmentType table, it plays a vital role in organizing equipment data and linking it to higher-level classifications via EquipmentClass.

Use this class as the foundation for data-driven features in the Irby Imaging application, ensuring each equipment type is uniquely identified and, if needed, related back to its equipment class.


Embrace the power of clear domain modeling! 🚀