diff --git a/Database-Attribute_System/QueryBuilder.cs b/Database-Attribute_System/QueryBuilder.cs index dd8262f..76d9345 100644 --- a/Database-Attribute_System/QueryBuilder.cs +++ b/Database-Attribute_System/QueryBuilder.cs @@ -138,7 +138,44 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System return BuildQuery(param); } - + public static string InsertAttributes(string tableName, Dictionary dbAttributes) + { + if (dbAttributes.Count == 0) throw new InvalidOperationException("Cannot generate SQL-Query. No attributes to insert."); + + List attributes = new List() { }; + List data = new List() { }; + + foreach (KeyValuePair attribute in dbAttributes) + { + attributes.Add(attribute.Key); + data.Add(attribute.Value); + } + + return InsertAttributes(tableName, attributes, data); + } + public static string InsertAttributes(string tableName, List attributes, List data) + { + if (attributes.Count != data.Count) throw new InvalidOperationException("Cannot generate SQL-Query. Attribute-count and data-count not equal."); + + string attributesSeperatedByComma = ""; + object[] attributeData = new object[attributes.Count*2]; + int c = 0; + for(int i=0; i