πŸ“” County.cs Documentation

File: IrbyImaging.DomainClasses/County.cs
Namespace: IrbyImaging.DomainClasses
Type: Entity / Data Model


πŸ“‘ Table of Contents

  1. πŸ“Œ Overview & Purpose
  2. 🧱 Dependencies & Technologies
  3. πŸ”‘ Key Functional Areas
  4. πŸ“Š Data Model: County Class
  5. πŸ“¦ Helper Methods & Utilities
  6. πŸ›  Error Handling & Return Types
  7. πŸ”Œ API Endpoints Overview
  8. 🌐 Third‑party Integrations
  9. πŸ’» Sample Code Blocks
  10. πŸš€ Usage Examples
  11. 🧩 UML Diagram
  12. πŸŽ‰ Conclusion

πŸ“Œ Overview & Purpose

The County class represents a geographical county entity in the Irby Imaging system.
Its primary roles are:

  • πŸ“ Data Storage: Map county details (name, location, timezone) to the database.
  • πŸ”— Entity Framework Integration: Leverage Data Annotations for schema mapping.
  • πŸ”Ž Querying: Serve as a domain class for CRUD operations via EF DbContext.

🧱 Dependencies & Technologies

Dependency Purpose
System Base .NET types (e.g., Guid, String).
System.Collections.Generic (Imported but not used) – for future collection properties.
System.ComponentModel.DataAnnotations Enables [Key], validation, and schema attribute usage.
System.ComponentModel.DataAnnotations.Schema Defines [Table] and mapping to the database schema.
Microsoft.EntityFrameworkCore (implied) ORM for interacting with relational databases.

πŸ”‘ Key Functional Areas

  1. Schema Mapping

    • [Table("County", Schema = "irby")]
      Maps this class to the irby.County table in the database.
  2. Primary Key Definition

    • [Key] public Guid CountyId { get; set; }
      Declares CountyId as the unique identifier.
  3. Geographical & Administrative Data

    • Properties for Name, City, State, Coordinates, TimeZone, etc.

πŸ“Š Data Model: County Class

4.1 Class Signature & Attributes

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

namespace IrbyImaging.DomainClasses
{
    [Table("County", Schema = "irby")]
    public class County
    {
        [Key]
        public Guid CountyId { get; set; }
        // ... other properties ...
    }
}
  • [Table]
    • Specifies the target table (County) and schema (irby).
  • [Key]
    • Marks CountyId as the primary key for EF.

4.2 Properties Reference

Property Type Required? Description
CountyId Guid Yes PK: Unique identifier for the county.
CountyName string Yes Official name (e.g., β€œOrange County”).
City string No Primary city within the county.
State string No Full state name (e.g., β€œCalifornia”).
StateCode string No Two‐letter postal code (e.g., β€œCA”).
AreaCode string No Telephone area code (e.g., β€œ714”).
Latitude string No Latitude coordinate (e.g., β€œ33.7175”).
Longitude string No Longitude coordinate (e.g., β€œ-117.8311”).
TimeZone string No Time zone identifier (e.g., β€œPST”).

Tip: Consider using numeric types (decimal) for coordinates to enable spatial queries.


πŸ“¦ Helper Methods & Utilities

None in this class.
This is purely a data model. All logic, validation, or utility methods should be implemented elsewhere (e.g., repositories, services).


πŸ›  Error Handling & Return Types

  • No direct error handling within this POCO.
  • Error handling is expected at the service or repository layer that consumes this class.

πŸ”Œ API Endpoints Overview

None in this file.
This class is a plain domain entity. API controllers should map DTOs or ViewModels to this model.


🌐 Third‑party Integrations

  • Entity Framework Core
    • Relies on EF conventions and Data Annotations for mapping.
  • (Potential) Geo-spatial libs if coordinates become numeric.

πŸ’» Sample Code Blocks

1. EF DbContext Setup

public class IrbyContext : DbContext
{
    public DbSet<County> Counties { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Apply Data Annotations
        modelBuilder.Entity<County>();
    }
}

2. LINQ Query Example

using (var db = new IrbyContext())
{
    var californiaCounties = db.Counties
        .Where(c => c.StateCode == "CA")
        .OrderBy(c => c.CountyName)
        .ToList();
}

πŸš€ Usage Examples

Creating & Saving a New County

var newCounty = new County
{
    CountyId   = Guid.NewGuid(),
    CountyName = "Travis",
    City       = "Austin",
    State      = "Texas",
    StateCode  = "TX",
    AreaCode   = "512",
    Latitude   = "30.2672",
    Longitude  = "-97.7431",
    TimeZone   = "CST"
};

using (var db = new IrbyContext())
{
    db.Counties.Add(newCounty);
    db.SaveChanges();
}

Updating an Existing County

using (var db = new IrbyContext())
{
    var county = db.Counties.Find(existingGuid);
    if (county != null)
    {
        county.City = "New City Name";
        db.SaveChanges();
    }
}

🧩 UML Diagram

@startuml
package IrbyImaging.DomainClasses {
    class County {
        + Guid CountyId
        + string CountyName
        + string City
        + string State
        + string StateCode
        + string AreaCode
        + string Latitude
        + string Longitude
        + string TimeZone
    }
}
@enduml

County UML Diagram


πŸŽ‰ Conclusion

The County class is a simple yet essential data model within the Irby Imaging domain. It provides:

  • A clear mapping to the irby.County table.
  • A foundation for CRUD operations in the repository/service layers.
  • A blueprint for storing geographical and administrative information.

Feel free to extend this class with methods (e.g., validation, computed properties), or convert string‐based coordinates into numeric types for advanced spatial queries.