public MergedReleaseDetails AddReleases(IEnumerable<ReleasePersistencyItem> data)
        { 
            var summary = new MergedReleaseDetails();

            using (var connection = _sqlFactory.CreateDbConnection())
            {
                connection.Open();

                // Pull out the existing 
                var currentRecords = connection.Query<ReleasePersistencyItem>(_selectReleases).ToDictionary(x => x.GetKey(), x => x, StringComparer.OrdinalIgnoreCase);

                summary.ExistingRecordsFound = currentRecords.Count;

                // Rip through the data we have
                foreach (var record in data)
                {
                    // See if the record already exists
                    var currentRecord = currentRecords.GetValueOrDefault(record.GetKey()); 
                    if (currentRecord != null)
                    {
                        if (record.GetHashCode() != currentRecord.GetHashCode())
                        {
                            // Need to get our ID
                            record.Id = currentRecord.Id;

                            // Update record because the data has changed
                            connection.Update(record);
                            summary.RecordsUpdated++;
                        }
                    }
                    else
                    {
                        // Insert record because we don't have it 
                        connection.Insert(record);
                        summary.RecordsAdded++;
                    } 
                }
            }

            return summary;
        }
        public MergedReleaseDetails AddReleases(IEnumerable <ReleasePersistencyItem> data)
        {
            var summary = new MergedReleaseDetails();

            using (var connection = _sqlFactory.CreateDbConnection())
            {
                connection.Open();

                // Pull out the existing
                var currentRecords = connection.Query <ReleasePersistencyItem>(_selectReleases).ToDictionary(x => x.GetKey(), x => x, StringComparer.OrdinalIgnoreCase);

                summary.ExistingRecordsFound = currentRecords.Count;

                // Rip through the data we have
                foreach (var record in data)
                {
                    // See if the record already exists
                    var currentRecord = currentRecords.GetValueOrDefault(record.GetKey());
                    if (currentRecord != null)
                    {
                        if (record.GetHashCode() != currentRecord.GetHashCode())
                        {
                            // Need to get our ID
                            record.Id = currentRecord.Id;

                            // Update record because the data has changed
                            connection.Update(record);
                            summary.RecordsUpdated++;
                        }
                    }
                    else
                    {
                        // Insert record because we don't have it
                        connection.Insert(record);
                        summary.RecordsAdded++;
                    }
                }
            }

            return(summary);
        }