/// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet Clearings. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddToClearings(Clearing clearing)
 {
     base.AddObject("Clearings", clearing);
 }
 /// <summary>
 /// Создание нового объекта Clearing.
 /// </summary>
 /// <param name="id">Исходное значение свойства Id.</param>
 /// <param name="requirements">Исходное значение свойства Requirements.</param>
 /// <param name="calculationByBughaltery">Исходное значение свойства CalculationByBughaltery.</param>
 /// <param name="calculationHot">Исходное значение свойства CalculationHot.</param>
 public static Clearing CreateClearing(global::System.Int32 id, global::System.Double requirements, global::System.Double calculationByBughaltery, global::System.Double calculationHot)
 {
     Clearing clearing = new Clearing();
     clearing.Id = id;
     clearing.Requirements = requirements;
     clearing.CalculationByBughaltery = calculationByBughaltery;
     clearing.CalculationHot = calculationHot;
     return clearing;
 }
        private void Calculate()
        {
            if (SelectedInterval == null || SelectedBuilding == null)
                return;

            var heatMeterReadings = Double.Parse(HeatMeterReadings);
            var waterMeterReadings = Double.Parse(WaterMeterReadings);

            var meterReadings = new MeterReading
                                    {
                                        CurrentHeatMeterReader = heatMeterReadings,
                                        CurrentWaterHeatReader = waterMeterReadings,
                                        DateTimeInterval = SelectedInterval,
                                        Building = SelectedBuilding
                                    };
            clearingRepository.InsertMeterReading(meterReadings);

            var clearing = new Clearing
                               {
                                   Requirements = Double.Parse(Requirements),
                                   CalculationByBughaltery = Double.Parse(WaterBuxgalter),
                                   DateTimeInterval = SelectedInterval,
                                   Building = SelectedBuilding,
                                   CalculationHot =
                                       totalCalculator.TotalHeatConsumption(Double.Parse(Requirements),
                                                                            Double.Parse(WaterBuxgalter))
                               };
            /*
            var totalHeatConsumption =
                clearingRepository.GetContractConsumptions().Where(item => item.BuildingsId == SelectedBuilding.Id &&
                                                                           item.DateTimeImtervals.Id == SelectedInterval.Id).Select(x => x.TotalHeatConsumption).Single();

            clearing.CalculationHot = totalCalculator.TotalHeatConsumption(totalHeatConsumption, Double.Parse(WaterBuxgalter));
             */

            clearingRepository.InsertClearing(clearing);
            clearingRepository.Save();
            Clearings.Add(clearing);
        }