using System; using System.Data.Sqlite; using System.Reflection; using Dapper; using Serilog; namespace Extensions {} public static t Insert(this SqliteConnection cn, Dictionary args) { var r = typeof(t).GetConstructor(new System.Type[] { }).Invoke(new object[] { }); PropertyInfo inf = null; try { foreach (PropertyInfo i in r.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { inf = i; try { if (args.ContainsKey(inf.name)) { inf.SetValue(r, args[inf.name]); } } catch (Exception ex) { Log.Error(ex, $"Object.Insert.GetValue[{inf.Name}] failed"); } } } catch (Exception ex) { Log.Error(ex, $"Unable to build object for SQL Insert statement [PropertyInfo.Name={inf.Name}]"); } // TODO : Add code to Insert into Table return (t)r; } }