mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
minor refactor
This commit is contained in:
parent
d04fc2a4e7
commit
1c0cdf9e12
1 changed files with 3 additions and 3 deletions
|
|
@ -36,7 +36,7 @@ private static void InsertOnDuplicateKeyUpdate<TEntityType>(this DbContext dbCon
|
|||
var properties = GetPropertiesLessValueGeneratedTimestamps(entityType);
|
||||
var values = CreateValues<TEntityType>(properties, dataPath);
|
||||
if (values == "") return;
|
||||
var columns = string.Join(", ", Enumerable.Select<IProperty, string>(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<IProperty> GetPropertiesLessValueGeneratedTimestamps(IEntity
|
|||
|
||||
private static string CreateValues<TEntityType>(IReadOnlyCollection<IProperty> properties, string dataPath)
|
||||
{
|
||||
return Enumerable.Select<TEntityType, string>(GetSeedRows<TEntityType>(dataPath), row => CreateRowValues(properties, row)).Aggregate("",
|
||||
return GetSeedRows<TEntityType>(dataPath).Select(row => CreateRowValues(properties, row)).Aggregate("",
|
||||
(current, rowValues) => current == "" ? rowValues : current + ", " + rowValues);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ private static string CreateRowValues<TEntityType>(IEnumerable<IProperty> proper
|
|||
{
|
||||
return (from property in properties
|
||||
let value = row.GetType().GetProperty(property.Name).GetValue(row)
|
||||
select FormatDataForMySql(property, value)).Aggregate<object, string>("",
|
||||
select FormatDataForMySql(property, value)).Aggregate("",
|
||||
(rowValues, value) => rowValues == "" ? "(" + value : rowValues + ", " + value) + ")";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue