static DBTableStruct CreateColum(this DBTableStruct table, string name, object defaultvalue, bool autoincreasment = false, bool uniquekey = false) { if (table.Colums.ContainsKey(name)) { throw new Exception(string.Format("already existed table colum {0}.", name)); } DBColum Colum = table.Colums.GetOrAdd(name, DBColum.Create(name, defaultvalue, autoincreasment, uniquekey)); if (OnCreateColum != null) { OnCreateColum.Invoke(table); } return(table); }
static DBTableStruct CreateTable(this string name, bool crypted) { if (Manager.ContainsKey(name)) { throw new Exception("already existed table."); } DBTableStruct table = DBTableStruct.Create(name, crypted); Manager.Add(name, table); if (OnCreateTable != null) { OnCreateTable.Invoke(table); } return(table); }
public static DBTableStruct Create(string name, bool Crypted = false) { var table = new DBTableStruct() { Name = name, CryptoGraphieKey = string.Empty, Colums = new ConcurrentDictionary <string, DBColum>() }; if (Crypted) { table.CryptoGraphieKey = CoreResolver.RandomizedCryptionKey(name); } return(table); }
static async void OnCreateColumVoid(DBTableStruct table) { int maxValues = table.Colums.Values.OrderByDescending(p => p.Values.Count).FirstOrDefault().Values.Count; foreach (DBColum colum in table.Colums.Values.Where(p => p.Values.Count < maxValues)) { int neededvalues = maxValues - colum.Values.Count; await Task.Run(() => { while (neededvalues > 0) { colum.Add(colum.DefaultValue); --neededvalues; } }); } }
static async void OnCreateTableVoid(DBTableStruct table) { await Task.Run(() => { }); }