Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fluent nhibernate Fluent Nhibernate映射到类属性或生成计算属性的方法?_Fluent Nhibernate - Fatal编程技术网

Fluent nhibernate Fluent Nhibernate映射到类属性或生成计算属性的方法?

Fluent nhibernate Fluent Nhibernate映射到类属性或生成计算属性的方法?,fluent-nhibernate,Fluent Nhibernate,我有一个带有边界框的类,我想有一些子类,根据它们的属性设置边界框的值 公共类LocationGeographicPointMap:子类映射 { 公共位置地理点地图(){ Map(x=>x.Latitude).Not.Nullable(); Map(x=>x.Longitude).Not.Nullable(); Map(x=>x.SpatialReferenceSystemCode).Nullable(); 地图(x=>x.North)。函数(m=>m.Latitude); 地图(x=>x.

我有一个带有边界框的类,我想有一些子类,根据它们的属性设置边界框的值




公共类LocationGeographicPointMap:子类映射
{
公共位置地理点地图(){
Map(x=>x.Latitude).Not.Nullable();
Map(x=>x.Longitude).Not.Nullable();
Map(x=>x.SpatialReferenceSystemCode).Nullable();
地图(x=>x.North)。函数(m=>m.Latitude);
地图(x=>x.South)。函数(m=>m.Latitude);
地图(x=>x.East)。函数(m=>m.Longitude);
地图(x=>x.West)。函数(m=>m.经度);
}

有办法做到这一点吗?

尽管如此,我们还是决定创建一个额外的逻辑层,将它放在层中。只需使用NHibernate作为存储层

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);   
}