Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract partial class AlertSpecification
- {
- private long _alertSpecificationId;
- private string _specificationName;
- private bool _active;
- private int _createdBy;
- private DateTime _createdOn;
- public virtual long AlertSpecificationId
- {
- get { return _alertSpecificationId; }
- set { _alertSpecificationId = value; }
- }
- public virtual string SpecificationName
- {
- get { return _specificationName; }
- set { _specificationName = value; }
- }
- public virtual bool Active
- {
- get { return _active; }
- set { _active = value; }
- }
- public virtual int CreatedBy
- {
- get { return _createdBy; }
- set { _createdBy = value; }
- }
- public virtual DateTime CreatedOn
- {
- get { return _createdOn; }
- set { _createdOn = value; }
- }
- }
- public partial class ComponentSpecification : AlertSpecification
- {
- private string _vehicleType;
- public virtual string VehicleType
- {
- get { return _vehicleType; }
- set { _vehicleType = value; }
- }
- }
- public partial class ColdVehicleSpecification : AlertSpecification
- {
- private double _sigmaThreshold;
- public virtual double SigmaThreshold
- {
- get { return _sigmaThreshold; }
- set { _sigmaThreshold = value; }
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
- namespace="IS.QueryPerformanceTest.Model" assembly="IS.QueryPerformanceTest.Model" >
- <class name="AlertSpecification" abstract="true">
- <cache usage="read-write"/>
- <id name="AlertSpecificationId" type="Int64">
- <generator class="hilo"/>
- </id>
- <property name="SpecificationName" column="Name" />
- <property name="Active" />
- <property name="CreatedBy" />
- <property name="CreatedOn" />
- <union-subclass name="ColdVehicleSpecification" table="AlertSpecificationColdVehicle">
- <property name="SigmaThreshold" column="CVSigmaThreshold" />
- </union-subclass>
- <union-subclass name="ComponentSpecification" table="AlertSpecificationComponent">
- <property name="VehicleType" column="VehicleType" />
- </union-subclass>
- </class>
- </hibernate-mapping>
- var repo = new NHComponentSpecificationRepository(ObjectFactory.GetInstance<ISession>
- ());
- var cvRepo = new
- NHColdVehicleSpecificationRepository(ObjectFactory.GetInstance<ISession>());
- var allComponentSpecs = repo.FindAll();
- var allColdVehicleSpecs = cvRepo.FindAll();
- public IList<ColdVehicleSpecification> FindAll()
- {
- var result = _session.Query<ColdVehicleSpecification>().ToList();
- return result;
- }
- ComponentSpecification cs = new ComponentSpecification ();
- session.Store(cs);
- var csId = cs.Id;
- // later on,
- // crashes with a cast exception
- var cvs = session.Get<ColdVehicleSpecification>(csId);
Add Comment
Please, Sign In to add comment