static void Add(this DBColum colum, long time, object newvalue, out Exception exp) { exp = null; try { if (!CoreResolver.CanUse(colum, newvalue)) { throw new WrongParameterCodeType("{0} type isn't acceptable in colum {1}.", CoreResolver.ReturnType(newvalue.GetType()).ToString(), colum.Name); } if (CoreResolver.UniqueDBKey(colum)) { if (colum.Values.Contains(newvalue)) { throw new DuplicatedUniqueValue("{0} unique value {1} existed already.", colum.Name, newvalue); } } colum.Records.Add(DBColumOrderRecord.Create(DBColumOrderRecordType.Add, time, colum, newvalue)); colum.UpdatedValue = newvalue; colum.Values.Add(newvalue); } catch (Exception e) { exp = e; } }
static object Get(this DBColum colum, long time, int index) { if (colum.Values.Count < index) { return(null); } colum.Records.Add(DBColumOrderRecord.Create(DBColumOrderRecordType.Get, time, colum.Name, colum.Values[index], colum.DefaultValue)); return(colum.Values[index]); }