/// <summary> /// Default constructor /// </summary> public DataFieldAttribute() { FieldLength = -1; //wanted to use nullable, no go with attributes SetOnInsert = true; LoadField = true; RelationshipType = ForeignKeyType.Cascade; FieldType = FieldType.Default; }
private ForeignKeyViolationException(ForeignKeyType type, string fromRelvar, string toRelvar, Obj[] fromTuple, Obj[] toTuple) { this.type = type; this.fromRelvar = fromRelvar; this.toRelvar = toRelvar; this.fromTuple = fromTuple; this.toTuple = toTuple; }
public override bool Equals(object obj) { TypeFk compareTo = obj as TypeFk; if (compareTo != null) { return(PrimaryKeyType.Equals(compareTo.PrimaryKeyType) && ForeignKeyType.Equals(compareTo.ForeignKeyType)); } return(base.Equals(obj)); }
/// <summary> /// Translates the a foreign key constraint to a sql friendly string /// </summary> /// <param name="foreignKeyType">Type of the foreign key.</param> /// <returns></returns> public virtual string TranslateFkeyType(ForeignKeyType foreignKeyType) { switch (foreignKeyType) { case ForeignKeyType.Cascade: return("Cascade"); case ForeignKeyType.NoAction: return("No Action"); case ForeignKeyType.SetNull: return("Set Null"); default: return(""); } }
/// <summary> /// Adds or updates the specified settings. /// </summary> /// <param name="type">The type of object these settings are associated with.</param> /// <param name="foreignKey">The ID of the object these settings are associated with.</param> /// <param name="settings">A collection of AbstractSetting instances to add or update. You need only set the SettingID and Value properties in each AbstractSetting instance.</param> private void AddOrUpdateSettings(ForeignKeyType type, int foreignKey, IEnumerable <AbstractSetting> settings) { db.RunInTransaction(() => { AbstractSetting[] existingSettings = GetSettings(type, foreignKey); foreach (AbstractSetting newSetting in settings) { AbstractSetting existingSetting = existingSettings.FirstOrDefault(s => s.SettingsID == newSetting.SettingsID); if (existingSetting != null) { existingSetting.Value = newSetting.Value; db.Update(existingSetting); } else { newSetting.ForeignKeyType = type; newSetting.ForeignKey = foreignKey; db.Insert(newSetting); } } }); }
private AbstractSetting[] GetSettings(ForeignKeyType type, int foreignKey) { return(db.Table <AbstractSetting>().Where(s => s.ForeignKeyType == type && s.ForeignKey == foreignKey).ToArray()); }