GeoLocation.cs Documentation ππΊοΈ
Table of Contents
- Overview π
- Purpose π―
- Dependencies & Technologies βοΈ
- GeoLocation Model π·οΈ
- Usage Examples π
- UML Class Diagram π§©
- Conclusion π
1. Overview π
The GeoLocation class is a domain model within the IrbyImaging.DomainClasses namespace. It serves as a representation of geospatial data (latitude/longitude) and rich metadata about a property or lease record, typically sourced from document images. This POCO (Plain Old CLR Object) is designed to be mapped by Entity Framework Core to a keyless database object (e.g., a view or raw SQL result).
2. Purpose π―
- Consolidate Geospatial & Lease Data: Combine map coordinates with property/lease attributes in a single consumable object.
- Reporting & Analytics: Enable easy querying of location-based metrics alongside lease details (rent, dates, taxes).
- Read-Only Mapping: Decorated with
_Keyless_to reflect database views or queries that do not have a single primary key.
3. Dependencies & Technologies βοΈ
| Technology / Package | Purpose |
|---|---|
| Microsoft.EntityFrameworkCore | ORM for mapping the GeoLocation class to database views or queries. |
| System (Collections, LINQ, Thread) | Core .NET namespaces for data structures, LINQ operations, and tasks. |
4. GeoLocation Model π·οΈ
using Microsoft.EntityFrameworkCore;
using System;
namespace IrbyImaging.DomainClasses
{
[Keyless]
public class GeoLocation
{
public Guid DocumentImageId { get; set; }
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
public string PropertyName { get; set; }
public string Address { get; set; }
// ... (other lease/property fields)
public string MonthlyInsurancePayment { get; set; }
}
}
4.1 Data Annotations π
[Keyless]
Indicates to EF Core that this entity has no primary key, mapping to a database object (view or query) that isnβt updatable in the usual way.
4.2 Property Reference Table ποΈ
| Property | Type | Description |
|---|---|---|
| DocumentImageId | Guid |
Unique identifier for the source image/document. |
| Latitude, Longitude | decimal |
Geospatial coordinates of the property. |
| PropertyName | string |
Name or title of the property. |
| Address, StreetAddress | string |
Full mailing address lines. |
| City, State, Zip | string |
Location details. |
| County, RegionLead | string |
Administrative region and responsible lead. |
| OwnerType, PropertyType | string |
Categories for owner/asset classification. |
| RentableArea, LeaseTerm, LeasePurpose | string |
Lease dimensions and terms. |
| MonthlyBaseRent, TotalCost | string |
Financials (rent, cost, taxes). |
| ContractDate, CommencementDate, ExpirationDate | string |
Key lease dates. |
| Landlord, LeaseCode | string |
Administrative identifiers. |
| FullyExecuted, SubjectToEscalation, MonthToMonth, QuantaReviewed | string |
Flags & review metadata. |
| BlobName | string |
Identifier for a related blob-storage object. |
| MonthlySalesTax, MonthlyAVTax, MonthlyInsurancePayment | string |
Recurring cost breakdown. |
5. Usage Examples π
5.1 EF Core Configuration π§
In your DbContext:
public class ApplicationDbContext : DbContext
{
public DbSet<GeoLocation> GeoLocations { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Map to a database view or raw SQL result
modelBuilder.Entity<GeoLocation>()
.HasNoKey()
.ToView("vw_GeoLocations");
}
}
5.2 CRUD Operations πΎ
Note: Keyless entities are read-only in EF Core. You cannot
AddorUpdatethem directly.
Read all records:
var allLocations = await dbContext.GeoLocations.ToListAsync();
Tip: Use
.FromSqlRaw()for complex queries or filtering at the database level:
var seattleLeases = await dbContext.GeoLocations
.FromSqlRaw("SELECT * FROM vw_GeoLocations WHERE City = {0}", "Seattle")
.ToListAsync();
5.3 LINQ Queries π
// Filter by latitude range
var westCoast = dbContext.GeoLocations
.Where(g => g.Longitude < -115M && g.Latitude > 32M)
.OrderBy(g => g.City)
.Select(g => new { g.PropertyName, g.City, g.MonthlyBaseRent })
.ToList();
6. UML Class Diagram π§©
classDiagram
class GeoLocation {
<<Keyless>>
+Guid DocumentImageId
+decimal Latitude
+decimal Longitude
+string PropertyName
+string Address
+string City
+string State
+string Zip
+string RentableArea
+string LeaseTerm
+string MonthlyBaseRent
+string TotalCost
+string ContractDate
+string CommencementDate
+string ExpirationDate
+string MonthlySalesTax
+string MonthlyAVTax
+string MonthlyInsurancePayment
+string BlobName
// ... other fields
}
7. Conclusion π
The GeoLocation class provides a flexible, read-only structure to combine geographic coordinates with a wide array of lease and property details. By leveraging Entity Framework Coreβs keyless entities, you can map this class to database views or raw SQL queriesβenabling rich reporting, filtering, and analytics in your .NET applications. Whether youβre building a property management dashboard, location-based reporting, or image-driven data pipelines, GeoLocation is your goβto model for highβvalue metadata integration.
Happy Coding! β¨