public ReflectionTableColumn(IDatabaseDialect dialect, PropertyInfo prop, Type declaredColumnType, bool isNullable) { Property = prop ?? throw new ArgumentNullException(nameof(prop)); Dialect = dialect ?? throw new ArgumentNullException(nameof(dialect)); if (declaredColumnType == null) { throw new ArgumentNullException(nameof(declaredColumnType)); } Name = dialect.GetAliasOrDefault(prop); var clrType = GetClrType(declaredColumnType); if (clrType == null) { throw new ArgumentNullException($"The declared column type does not implement IDbType<T>. Check { prop.ReflectedType.FullName }.{ prop.Name } and ensure that the column type { declaredColumnType.FullName } implements this interface.", nameof(declaredColumnType)); } var columnType = new ReflectionColumnDataType(dialect, declaredColumnType, clrType); var autoIncrAttr = dialect.GetDialectAttribute <AutoIncrementAttribute>(declaredColumnType) ?? dialect.GetDialectAttribute <AutoIncrementAttribute>(prop); if (autoIncrAttr != null) { if (!ValidAutoIncrementTypes.Contains(columnType.DataType)) { throw new ArgumentNullException($"The column { prop.ReflectedType.FullName }.{ prop.Name } is declared as being auto incrementing, which is not supported on a '{ columnType.DataType }' data type.", nameof(declaredColumnType)); } AutoIncrement = new AutoIncrement(autoIncrAttr.InitialValue, autoIncrAttr.Increment); } Type = columnType; IsNullable = isNullable; }
public void SaveToStructure(AbstractObjectStructure obj) { var table = (TableStructure)obj; if (!String.IsNullOrEmpty(Engine)) { table.SpecificData["mysql.engine"] = Engine; } if (!String.IsNullOrEmpty(CharacterSet)) { table.SpecificData["mysql.character_set"] = CharacterSet; } if (!String.IsNullOrEmpty(Collation)) { table.SpecificData["mysql.collation"] = Collation; } if (AutoIncrement != null) { table.SpecificData["mysql.auto_increment"] = AutoIncrement.ToString(); } if (Checksum != null) { table.SpecificData["mysql.checksum"] = Checksum.Value ? "1" : "0"; } if (DelayKeyWrite != null) { table.SpecificData["mysql.delay_key_write"] = DelayKeyWrite.Value ? "1" : "0"; } }
public static void EqualsT_GivenNullIAutoIncrement_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); Assert.That(a.Equals(null), Is.False); }
public static void NotEqualsOpLeftIAutoIncrement_GivenNullIAutoIncrement_ReturnsTrue() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); Assert.That((FakeAutoIncrement)null != a, Is.True); }
public static void Increment_PropertyGet_EqualsCtorArgument() { const int initialValue = 12345; const int increment = 9876; var autoIncrement = new AutoIncrement(initialValue, increment); Assert.That(autoIncrement.Increment, Is.EqualTo(increment)); }
public static void EqualsOpRightIAutoIncrement_GivenNullIAutoIncrement_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); Assert.That(a == (FakeAutoIncrement)null, Is.False); }
public static void Equals_GivenObjectsWithDifferentInitialValue_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); object b = new AutoIncrement(54321, increment); Assert.That(a.Equals(b), Is.False); }
public static void Equals_GivenObjectsWithEqualInputs_ReturnsTrue() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); object b = new AutoIncrement(initialValue, increment); Assert.That(a.Equals(b), Is.True); }
public static void NotEqualsOpLeftIAutoIncrement_GivenObjectsWithEqualInputs_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new FakeAutoIncrement(initialValue, increment); var b = new AutoIncrement(initialValue, increment); Assert.That(a != b, Is.False); }
public static void EqualsOpLeftIAutoIncrement_GivenObjectsWithDifferentInitialValue_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new FakeAutoIncrement(initialValue, increment); var b = new AutoIncrement(54321, increment); Assert.That(a == b, Is.False); }
public static void EqualsOpRightIAutoIncrement_GivenObjectsWithEqualInputs_ReturnsTrue() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); var b = new FakeAutoIncrement(initialValue, increment); Assert.That(a == b, Is.True); }
public static void GetHashCode_GivenObjectsWithDifferentIncrement_AreNotEqual() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); var b = new AutoIncrement(initialValue, 6789); Assert.That(a.GetHashCode(), Is.Not.EqualTo(b.GetHashCode())); }
public static VersionPart Value(this AutoIncrement self) { return(self switch { AutoIncrement.patch => VersionPart.Patch, AutoIncrement.minor => VersionPart.Minor, AutoIncrement.major => VersionPart.Major, _ => throw new ArgumentException("Unknown or invalid auto increment.", nameof(self)), });
public static void NotEqualsOpLeftIAutoIncrement_GivenObjectsWithDifferentIncrement_ReturnsTrue() { const int initialValue = 12345; const int increment = 9876; var a = new FakeAutoIncrement(initialValue, increment); var b = new AutoIncrement(initialValue, 6789); Assert.That(a != b, Is.True); }
public static void GetHashCode_GivenObjectsWithEqualInputs_AreEqual() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); var b = new AutoIncrement(initialValue, increment); Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode())); }
public static void Equals_GivenNonAutoIncrementObject_ReturnsFalse() { const int initialValue = 12345; const int increment = 9876; var a = new AutoIncrement(initialValue, increment); var b = new object(); Assert.That(a.Equals(b), Is.False); }
public HttpResponseMessage SaveBasItemCategoryForm(t_item_category obj) { using (TransactionScope transaction = new TransactionScope()) { DBHelper <t_item_category> dbhelp = new DBHelper <t_item_category>(); DateTime dt = DateTime.Now; //事务 var result = 0; var ItemCategory = db.t_item_category.Where(w => w.Code == obj.Code && w.CorpID == userInfo.CorpID); try { if (obj.ItemCategoryID == 0) { string Code = ""; result = AutoIncrement.AutoIncrementResult("ItemCategory", out Code); obj.CreateTime = dt; obj.CreateUser = (int)userInfo.UserID; obj.UPdateTime = dt; obj.UpdateUser = (int)userInfo.UserID; obj.CorpID = userInfo.CorpID; obj.Code = Code; if (ItemCategory.ToList().Count() > 0) { throw new Exception("编码重复!"); } } else { obj.UPdateTime = dt; obj.UpdateUser = (int)userInfo.UserID; if (ItemCategory.ToList().Count() > 1) { throw new Exception("编码重复!"); } } result = result + (obj.ItemCategoryID == 0 ? dbhelp.Add(obj) : dbhelp.Update(obj)); //提交事务 transaction.Complete(); return(Json(true, "保存成功!")); } catch (Exception ex) { return(Json(false, "保存失败!" + ex.Message)); } } }
public long GetNewID(string collectionName, string fieldName = "ID", long addValue = 1, long def = 1) { var model = new AutoIncrement() { ID = 1, CollectionName = collectionName, FieldName = fieldName, IncrementID = addValue }; //DbSet.Add(model); MySqlDb.GetInstance().Entry(model).State = EntityState.Modified; var res = MySqlDb.GetInstance().SaveChanges(); return(res); }
private void Continue() { if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtCode.Focus(); } else { txtCode.Text = ""; txtCode.Focus(); } }
private void Continue() { txtName.Text = txtAliasName.Text = txtAreaCode.Text = txtCapital.Text = txtNamePY.Text = ""; if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtName.Focus(); } else { txtCode.Text = ""; txtCode.Focus(); } }
private void Continue() { txtName.Text = ""; spinLower.EditValue = spinUpper.EditValue = null; if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtName.Focus(); } else { txtCode.Text = ""; txtCode.Focus(); } }
protected override string GetCreateTableSql() { var identity = "IDENTITY(1,1)"; StringBuilder builder = new StringBuilder($"USE {Schema.Database}; IF OBJECT_ID('{Schema.TableName}', 'U') IS NULL CREATE table {Schema.TableName} ("); StringBuilder columnNames = new StringBuilder(); if (Primary.Count == 0) { foreach (var p in Columns) { columnNames.Append($",[{p.Name}] {ConvertToDbType(p.DataType)} NULL"); } } else { foreach (var p in Columns) { var identityPart = AutoIncrement.Contains(p.Name) ? identity : ""; var nullPart = Primary.Any(k => k.Name == p.Name) ? "NOT NULL" : "NULL"; columnNames.Append($",[{p.Name}] {ConvertToDbType(p.DataType)} {identityPart} {nullPart}"); } } builder.Append(columnNames.ToString().Substring(1, columnNames.Length - 1)); builder.Append(Primary == null || Primary.Count == 0 ? (columnNames.Length == 0 ? "" : ",") + "[__id] [int] IDENTITY(1,1) NOT NULL," : ","); string primaryKey = Primary == null || Primary.Count == 0 ? "[__id] ASC" : string.Join(", ", Primary.Select(p => $"[{p.Name}] ASC")); builder.Append( $" CONSTRAINT [PK_{Schema.TableName}] PRIMARY KEY CLUSTERED ({primaryKey.Substring(0, primaryKey.Length)})WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON[PRIMARY]) ON[PRIMARY];"); foreach (var index in Indexs) { string name = string.Join("_", index.Select(c => c)); string indexColumNames = string.Join(", ", index.Select(c => $"[{c}]")); builder.Append($"CREATE NONCLUSTERED INDEX [index_{name}] ON {Schema.TableName} ({indexColumNames.Substring(0, indexColumNames.Length)});"); } foreach (var unique in Uniques) { string name = string.Join("_", unique.Select(c => c)); string uniqueColumNames = string.Join(", ", unique.Select(c => $"[{c}]")); builder.Append($"CREATE UNIQUE NONCLUSTERED INDEX [unique_{name}] ON {Schema.TableName} ({uniqueColumNames.Substring(0, uniqueColumNames.Length)});"); } return(builder.ToString()); }
/// <summary> /// 保存 /// </summary> private void Continue() { if (checkBox1.Checked) { textEdit1.Text = AutoIncrement.NextCode(textEdit1.Text.Trim()); if (textEdit1.Text == "A") { textEdit1.Text = Convert.ToString(10); } textEdit1.Focus(); } else { textEdit1.Text = ""; textEdit1.Focus(); } }
public override int GetHashCode() { unchecked { int result = base.GetHashCode(); result = (result * 397) ^ (Type != null ? Type.GetHashCode() : 0); result = (result * 397) ^ AutoIncrement.GetHashCode(); result = (result * 397) ^ Seed; result = (result * 397) ^ Increment; result = (result * 397) ^ Nullable.GetHashCode(); result = (result * 397) ^ Size.GetHashCode(); result = (result * 397) ^ DecimalScale; result = (result * 397) ^ DecimalPrecision; result = (result * 397) ^ (DefaultValue != null ? DefaultValue.GetHashCode() : 0); return(result); } }
private void Continue() { txtName.Text = ""; txtBrand.Text = ""; spinEditPrice.Value = 0; spinSortOrder.Value = spinSortOrder.Value + 1; if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtName.Focus(); } else { txtCode.Text = ""; txtCode.Focus(); } }
private void Continue() { txtName.Text = ""; txtNameS.Text = ""; txtContact.Text = ""; txtPhone.Text = ""; txtAddress.Text = ""; txtPostcode.Text = ""; if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtName.Focus(); } else { txtCode.Text = ""; txtCode.Focus(); } }
public ActionResult Create([FromBody] Transaction transaction) { FirebaseResponse countGetResponse = client.Get("AI"); if (countGetResponse.Body == "null") { SetResponse countSet = client.Set("AI/Count", 0); countGetResponse = client.Get("AI"); } AutoIncrement countInstance = countGetResponse.ResultAs <AutoIncrement>(); transaction.Id = countInstance.Count; SetResponse transactionResponse = client.Set("Transaction/" + countInstance.Count, transaction); countInstance.Count++; FirebaseResponse countUpdateResponse = client.Update("AI", countInstance); return(new ObjectResult(transaction)); }
void Continue() { txtName.Text = ""; if (checkAutoIncrement.Checked) { txtCode.Text = AutoIncrement.NextCode(txtCode.Text.Trim()); txtName.Focus(); } else { txtRemark.Text = txtCode.Text = ""; txtCode.Focus(); } comboIsActive.SelectedIndex = 0; List <RoleEntity> roles = bindingSource1.DataSource as List <RoleEntity>; roles.ForEach(r => r.Checked = false); gridControl1.RefreshDataSource(); }
public override int GetHashCode() { int hash = 1; if (AutoIncrement != 0L) { hash ^= AutoIncrement.GetHashCode(); } if (Branch.Length != 0) { hash ^= Branch.GetHashCode(); } if (Revision.Length != 0) { hash ^= Revision.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public string GetPropertiesAsXml() { StringBuilder sbResult = new StringBuilder(); sbResult.Append("<" + (String.IsNullOrEmpty(ColumnName) ? "_" : ColumnName) + GetRegexProperties()); if (!String.IsNullOrEmpty((PrecedingRegEx ?? "").TrimEnd('"'))) { sbResult.Append(" Prefix = '" + PrecedingRegEx + "'"); } if (!String.IsNullOrEmpty((TrailingRegEx ?? "").TrimEnd('"'))) { sbResult.Append(" Suffix = '" + TrailingRegEx + "'"); } if (ColumnType != RegexColumnType.STRING) { sbResult.Append(" Type = '" + ColumnType.ToString() + "'"); } if (!String.IsNullOrEmpty(ValueMatchingCondition)) { sbResult.Append(" Condition = '" + ValueMatchingCondition + "'"); } if (AutoIncrement) { sbResult.Append(" AutoIncrement = '" + AutoIncrement.ToString() + "'"); } if (AutoIncrement) { sbResult.Append(" StartValue = '" + StartValue.ToString() + "'"); } if (AutoIncrement) { sbResult.Append(" Increment = '" + Increment.ToString() + "'"); } if (!String.IsNullOrEmpty(Expression)) { sbResult.Append(" Expression = '" + Expression + "'"); } if (IsForeignKey) { sbResult.Append(" ForeignKey = '" + IsForeignKey.ToString() + "'"); } if (IsUnique) { sbResult.Append(" PrimaryKey = '" + IsUnique.ToString() + "'"); } if (!String.IsNullOrEmpty(DisplayName)) { sbResult.Append(" DisplayName = '" + DisplayName + "'"); } if (!String.IsNullOrEmpty(Description)) { sbResult.Append(" Description = '" + Description + "'"); } if (!String.IsNullOrEmpty(Default)) { sbResult.Append(" Default = '" + Default + "'"); } sbResult.Append(" />"); return(sbResult.ToString()); }
public TesteObj() { autoIncrement += new AutoIncrement(sequence.Increment); }