public Query <T> Insert(object data) { var insert = new InsertStatement(); var props = data.GetType().GetRuntimeProperties(); foreach (var prop in props) { insert.Values.Add(prop.Name, prop.GetValue(data)); } CurrentMethod = insert; return(this); }
private string CompileInsertStatement(InsertStatement insert) { StringBuilder raw = new StringBuilder(); raw.Append($"INSERT INTO [{Table}]"); var cols = $" ({string.Join(", ", insert.Values.Keys.Select(x => $"[{x}]"))}) "; var vals = $" VALUES ({string.Join(", ", insert.Values.Values.Select(x => $"'{x}'"))})"; foreach (var item in cols) { raw.Append($"{item}"); } foreach (var item in vals) { raw.Append($"{item}"); } return(raw.ToString()); }