π County.cs Documentation
File:
IrbyImaging.DomainClasses/County.cs
Namespace:IrbyImaging.DomainClasses
Type: Entity / Data Model
π Table of Contents
- π Overview & Purpose
- π§± Dependencies & Technologies
- π Key Functional Areas
- π Data Model: County Class
- π¦ Helper Methods & Utilities
- π Error Handling & Return Types
- π API Endpoints Overview
- π Thirdβparty Integrations
- π» Sample Code Blocks
- π Usage Examples
- π§© UML Diagram
- π 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
-
Schema Mapping
[Table("County", Schema = "irby")]
Maps this class to theirby.Countytable in the database.
-
Primary Key Definition
[Key] public Guid CountyId { get; set; }
DeclaresCountyIdas the unique identifier.
-
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).
- Specifies the target table (
[Key]- Marks
CountyIdas the primary key for EF.
- Marks
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
π Conclusion
The County class is a simple yet essential data model within the Irby Imaging domain. It provides:
- A clear mapping to the
irby.Countytable. - 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.