public static string CreateFromContainer(string dataType, GenericDataContainer container) { var keyValuePairs = GenericDataContainerTraversal.Traverse(container); var query = $"UPDATE {dataType} SET "; var firstItem = true; foreach (var(key, value) in keyValuePairs) { if (key.InSet("Id", "CreatedTimeUtc", "OriginalSubmitter")) { continue; } if (!firstItem) { query += ", "; } else { firstItem = false; } if (key == "Id") { query += $"{key}={value}"; } else { query += $"{key}='{value}'"; } } query += $" WHERE Id='{container.Id}'"; return(query); }
public static string CreateFromContainer(string dataType, GenericDataContainer container) { var keyValuePairs = GenericDataContainerTraversal.Traverse(container); var query = $"INSERT INTO {dataType} ({string.Join(", ", keyValuePairs.Keys)}) " + $"VALUES ({string.Join(", ", keyValuePairs.Select(kvp => $"'{kvp.Value}'"))})"; return(query); }
private IEnumerable <string> GetColumnNamesFromContainer(GenericDataContainer container) { var keyValuePairs = GenericDataContainerTraversal.Traverse(container); return(keyValuePairs.Keys); }