From 1c0cdf9e128227e202884c7a748e40f18d90aa03 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Mon, 22 Jan 2018 16:23:17 -0600 Subject: [PATCH] minor refactor --- .../Seed/Extensions/SeedFilterListsDbContext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs b/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs index 1ffd67b49..701bfc2c1 100644 --- a/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs +++ b/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs @@ -36,7 +36,7 @@ private static void InsertOnDuplicateKeyUpdate(this DbContext dbCon var properties = GetPropertiesLessValueGeneratedTimestamps(entityType); var values = CreateValues(properties, dataPath); if (values == "") return; - var columns = string.Join(", ", Enumerable.Select(properties, x => x.Name)); + var columns = string.Join(", ", properties.Select(x => x.Name)); var updates = CreateUpdates(properties); var rawSqlString = "INSERT INTO " + entityType.Relational().TableName + " (" + columns + ") VALUES " + values + " ON DUPLICATE KEY UPDATE " + updates; @@ -52,7 +52,7 @@ private static List GetPropertiesLessValueGeneratedTimestamps(IEntity private static string CreateValues(IReadOnlyCollection properties, string dataPath) { - return Enumerable.Select(GetSeedRows(dataPath), row => CreateRowValues(properties, row)).Aggregate("", + return GetSeedRows(dataPath).Select(row => CreateRowValues(properties, row)).Aggregate("", (current, rowValues) => current == "" ? rowValues : current + ", " + rowValues); } @@ -74,7 +74,7 @@ private static string CreateRowValues(IEnumerable proper { return (from property in properties let value = row.GetType().GetProperty(property.Name).GetValue(row) - select FormatDataForMySql(property, value)).Aggregate("", + select FormatDataForMySql(property, value)).Aggregate("", (rowValues, value) => rowValues == "" ? "(" + value : rowValues + ", " + value) + ")"; }