/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [DistanceCosts] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual DistanceCosts Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, DistanceCosts copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((DistanceCosts)copiedObjects[this]); } copy = copy ?? new DistanceCosts(); if (!asNew) { copy.TransientId = this.TransientId; copy.Id = this.Id; } copy.TotalDistanceDriven = this.TotalDistanceDriven; copy.TotalDistanceService = this.TotalDistanceService; copy.OilCost = this.OilCost; copy.OilConsumption = this.OilConsumption; copy.TireCost = this.TireCost; copy.YearlyReparationCost = this.YearlyReparationCost; copy.Cost = this.Cost; copy.TireConsumption = this.TireConsumption; if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } copy.propulsionTypeCost = new List <PropulsionTypeCost>(); if (deep && this.propulsionTypeCost != null) { foreach (var __item in this.propulsionTypeCost) { if (!copiedObjects.Contains(__item)) { if (asNew && reuseNestedObjects) { copy.AddPropulsionTypeCost(__item); } else { copy.AddPropulsionTypeCost(__item.Copy(deep, copiedObjects, asNew)); } } else { copy.AddPropulsionTypeCost((PropulsionTypeCost)copiedObjects[__item]); } } } return(copy); }
/// <summary> /// Returns true if self and the provided entity have the same Id values /// and the Ids are not of the default Id value /// </summary> protected bool HasSameNonDefaultIdAs(DistanceCosts compareTo) { return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id)); }
public void Vehicule_persistence_test() { DateTime now = DateTime.Now; // Get datetime without milliseconds now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind); var _vehiculebo_distancecosts_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.DistanceCosts { TotalDistanceDriven = 222222.22M, TotalDistanceService = 222222.22M, OilCost = 222222.22M, OilConsumption = 222222.22M, TireCost = 222222.22M, YearlyReparationCost = 222222.22M, Cost = 222222.22M, TireConsumption = 222222.22M, }; var _vehiculebo_timecosts_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.TimeCosts { DriverSalary = 222222.22M, DriverWorkHours = 222222.22M, DriverServiceHours = 222222.22M, VehiculeHoursPerDay = 222222.22M, VehiculeDaysPerYear = 222222.22M, RoadTax = 222222.22M, VehiculeInsurance = 222222.22M, GoodsInssurance = 222222.22M, Maintainance = 222222.22M, DaysOfReplacementVehicules = 222222.22M, CostOfReplacement = 222222.22M, Cost = 222222.22M, }; var _vehiculebo_ownershipcost_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.OwnershipCost { VehiculePurchaseCost = 222222.22M, RefrigerationSystemCost = 222222.22M, LetteringCost = 222222.22M, InterestRate = 222222.22M, PaybackPeriod = 222222.22M, TotalDistancePerVehicule = 222222.22M, AmortizationPeriod = 222222.22M, ResidualValue = 222222.22M, UtilizationPeriod = 222222.22M, Cost = 222222.22M, }; var _vehiculebo_amortizationtype1_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.AmortizationType { Label = "AmortizationType_Label", }; new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.Vehicule>(Session) .CheckProperty(p => p.OverHeadCost, 222222.22M) .CheckProperty(p => p.CalculatedTimeCost, 222222.22M) .CheckProperty(p => p.CalculatedDistanceCost, 222222.22M) .CheckProperty(p => p.CalculatedOwnershipCost, 222222.22M) .CheckProperty(p => p.VehiculeType, "Vehicule_VehiculeType") .CheckProperty(p => p.Volume, "Vehicule_Volume") .CheckProperty(p => p.CO2perKm, 222222.22M) .CheckProperty(p => p.AmortizationType, "Vehicule_AmortizationType") .CheckProperty(p => p.MaximumLoad, 222222.22M) .CheckReference(p => p.DistanceCosts, _vehiculebo_distancecosts_vehicule) .CheckReference(p => p.TimeCosts, _vehiculebo_timecosts_vehicule) .CheckReference(p => p.OwnershipCost, _vehiculebo_ownershipcost_vehicule) .CheckReference(p => p.AmortizationType1, _vehiculebo_amortizationtype1_vehicule) .VerifyTheMappings(); }