GeoLocation.cs Documentation πŸ“πŸ—ΊοΈ


Table of Contents

  1. Overview πŸ“–
  2. Purpose 🎯
  3. Dependencies & Technologies βš™οΈ
  4. GeoLocation Model 🏷️
  5. Usage Examples πŸš€
  6. UML Class Diagram 🧩
  7. 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 Add or Update them 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! ✨