views:

53

answers:

1

I have a class with a bounding box, and I want to have subclasses that set the values of the bounding box, based on their attributes


public class LocationBase : BaseEntity
{

    public virtual int Id { get; set; }

    public virtual double North { get; set; }
    public virtual double East { get; set; }
    public virtual double South { get; set; }
    public virtual double West { get; set; }

    public virtual string SpatialReferenceSystemCode { get; set; }

    public LocationBase()
    {
        SpatialReferenceSystemCode = "EPSG:4236";
    }
}

public class LocationGeographicPoint : LocationBase
{

    public virtual double Longitude { get; set; }
    public virtual double Latitude { get; set; }

}


 public class LocationBaseMap : ClassMap<LocationBase>
    {
        public LocationBaseMap()

    {
        Table("Locations");
        Id(x => x.Id).Column("LocationId").GeneratedBy.Increment();
        Map(x => x.North).Not.Nullable();
        Map(x => x.West).Not.Nullable();
        Map(x => x.South).Not.Nullable();
        Map(x => x.East).Not.Nullable();
        Map(x => x.SpatialReferenceSystemCode).Default("EPSG:4326").Nullable();
    }
}


public class LocationGeographicPoint : LocationBase
{

    public virtual double Longitude { get; set; }
    public virtual double Latitude { get; set; }

}


 public class LocationGeographicPointMap : SubclassMap<LocationGeographicPoint>

    {
        public LocationGeographicPointMap() {

        Map(x => x.Latitude).Not.Nullable();
        Map(x => x.Longitude).Not.Nullable();
         Map(x => x.SpatialReferenceSystemCode).Nullable();

     Map(x => x.North).Function(m => m.Latitude);
     Map(x => x.South).Function(m => m.Latitude);     
     Map(x => x.East).Function(m => m. Longitude);
     Map(x => x.West).Function(m => m. Longitude);   
}

Is there a way to do this?

A: 

Though about it, and determined, create an additional logic layer, put it in the layer. Just use NHibernate as the storage layer

david valentine

related questions