Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        /// <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("");
            }
        }
Ejemplo n.º 5
0
 /// <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);
             }
         }
     });
 }
Ejemplo n.º 6
0
 private AbstractSetting[] GetSettings(ForeignKeyType type, int foreignKey)
 {
     return(db.Table <AbstractSetting>().Where(s => s.ForeignKeyType == type && s.ForeignKey == foreignKey).ToArray());
 }