public DatabaseAddin() { db = new DynamicModel("Database"); db.PrimaryKeyField = "id"; }
public static DynamicModel Open(string connectionStringName) { dynamic dm = new DynamicModel(connectionStringName); return dm; }
public SeedDatabaseAddin() { db = new DynamicModel("Database"); }
public static DynamicModel Open(string connectionStringName) { dynamic dm = new DynamicModel(connectionStringName); return(dm); }
public dynamic GetOrInsertTable(DynamicModel db, TableDesc tableModel,string keyName, string keyValue) { var result = db.All(where: string.Format("{0} = @0", keyName), args: new[] { keyValue }); var count = result.Count(); if (count == 0) { IDictionary<string, object> newContent = new ExpandoObject(); newContent[keyName] = keyValue; var fieldValues = (IDictionary<string, object>)tableModel.Values; foreach (string fieldName in fieldValues.Keys) { newContent[fieldName] = fieldValues[fieldName]; } return db.Insert(newContent); } else if (count == 1) { return result.First(); } else { throw new Exception(string.Format("Multiple content with same name {0}", keyName)); } }