/// <summary>
        /// Saves the specified composite egm meter datas.
        /// </summary>
        /// <param name="compositeEgmMeterDatas">The composite egm meter datas.</param>
        public void Save(ICollection <CompositeEgmMeterData> compositeEgmMeterDatas)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                foreach (var compositeEgmMeterData in compositeEgmMeterDatas)
                {
                    if (!context.CompositeEgmMeterDatas.Any(cemd => cemd.Id == compositeEgmMeterData.Id))
                    {
                        // no matching PK for this CompositeEgmMeterData in database,
                        // thus we create new entity and add it to db
                        DaoUtilities.SaveCreatedEntity(context, context.CompositeEgmMeterDatas, compositeEgmMeterData,
                                                       SetNewEntityState, false);
                    }
                    else
                    {
                        // matching PK found, thus we update state of existing CompositeEgmMeterData entity
                        DaoUtilities.SaveUpdatedEntity(context, context.CompositeEgmMeterDatas, compositeEgmMeterData,
                                                       UpdateExistingEntityState, false);
                    }
                }

                DaoUtilities.SaveToDbWithRetry(context, DaoUtilities.SaveType.UpdateExistingEntity,
                                               ResolveEntityUpdateConflict);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the specified egm metrics.
        /// </summary>
        /// <param name="egmMetrics">The egm metrics.</param>
        public void Save(ICollection <EgmMetric> egmMetrics)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                foreach (var egmMetric in egmMetrics)
                {
                    if (!context.EgmMetrics.Any(metric => metric.Id == egmMetric.Id))
                    {
                        // no matching PK for this EgmMetric in database,
                        // thus we create new entity and add it to db
                        DaoUtilities.SaveCreatedEntity(context, context.EgmMetrics, egmMetric,
                                                       SetNewEntityState, false);
                    }
                    else
                    {
                        // matching PK found, thus we update state of existing EgmMetric entity
                        DaoUtilities.SaveUpdatedEntity(context, context.EgmMetrics, egmMetric,
                                                       UpdateExistingEntityState, false);
                    }
                }

                DaoUtilities.SaveToDbWithRetry(context, DaoUtilities.SaveType.UpdateExistingEntity,
                                               ResolveEntityUpdateConflict);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the specified EgmMetric.
        /// </summary>
        /// <param name="egmMetric">The EgmMetric to save.</param>
        public void Save(EgmMetric egmMetric)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                if (!context.EgmMetrics.Any(metric => metric.Id == egmMetric.Id))
                {
                    // no matching PK for this EgmMetric in database,
                    // thus we create new entity and add it to db
                    DaoUtilities.SaveCreatedEntity(context, context.EgmMetrics, egmMetric, SetNewEntityState);
                }
                else
                {
                    // matching PK found, thus we update state of existing EgmMetric entity
                    DaoUtilities.SaveUpdatedEntity(context, context.EgmMetrics, egmMetric, UpdateExistingEntityState);
                }
            }
        }
        /// <summary>
        /// Saves the specified composite EGM meter data.
        /// </summary>
        /// <param name="compositeEgmMeterData">The composite EGM meter data.</param>
        public void Save(CompositeEgmMeterData compositeEgmMeterData)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                if (!context.CompositeEgmMeterDatas.Any(cemd => cemd.Id == compositeEgmMeterData.Id))
                {
                    // no matching PK for this CompositeEgmMeterData in database,
                    // thus we create new entity and add it to db
                    DaoUtilities.SaveCreatedEntity(context, context.CompositeEgmMeterDatas, compositeEgmMeterData,
                                                   SetNewEntityState);
                }
                else
                {
                    // matching PK found, thus we update state of existing CompositeEgmMeterData entity
                    DaoUtilities.SaveUpdatedEntity(context, context.CompositeEgmMeterDatas, compositeEgmMeterData,
                                                   UpdateExistingEntityState);
                }
            }
        }