public void Add(RatingsPredictionSchedule item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var entity = _dbContext.Find <PredictionSchedule>(new object[] { item.Id }, find => find.IncludeCollection(pb => pb.Ratings)); if (entity == null) { _ = _dbContext.Add( _mapper.Map <PredictionSchedule>(item, opts => opts.UseEntityCache(_salesAreaByNameCache)), post => post.MapTo(item, mappingOptions => mappingOptions.UseEntityCache(_salesAreaByIdCache)), _mapper); } else { _ = _mapper.Map(item, entity, opts => opts.UseEntityCache(_salesAreaByNameCache)); _ = _dbContext.Update(entity, post => post.MapTo(item, mappingOptions => mappingOptions.UseEntityCache(_salesAreaByIdCache)), _mapper); } }