public void Add(string userName, string roleName) { if (ReadOnly) { throw new NotSupportedException("Role storage is read only."); } var data = new Hashtable(); data[ResolveFieldName("User")] = userName; data[ResolveFieldName("Role")] = roleName; Dalc.Insert(UserRoleSourceName, data); }
public void Set(object fromKey, IEnumerable toKeys) { // load existing keys var currentToKeys = GetToKeys(fromKey); // remove missed relations var fromCondition = ComposeFromCondition(fromKey); var deleteCondition = fromCondition; var toKeysArr = toKeys.Cast <object>().ToArray(); if (toKeysArr.Length > 0) { deleteCondition = new QueryConditionNode((QField)ToFieldName, Conditions.In | Conditions.Not, new QConst(toKeysArr)) & deleteCondition; } Dalc.Delete(new Query(RelationSourceName, deleteCondition)); var data = ExtraKeys == null ? new Hashtable() : new Hashtable(new DictionaryWrapper <string, object>(ExtraKeys)); data[FromFieldName] = fromKey; int pos = 1; foreach (var toKey in toKeys) { data[ToFieldName] = toKey; if (PositionFieldName != null) { data[PositionFieldName] = pos++; } if (Contains(toKey, currentToKeys)) { if (PositionFieldName != null) { Dalc.Update(new Hashtable() { { PositionFieldName, data[PositionFieldName] } }, new Query(RelationSourceName, (QField)ToFieldName == new QConst(toKey) & fromCondition)); } } else { Dalc.Insert(data, RelationSourceName); } } }
private void SaveInternal(IDictionary data, IFileObject fileObject, string tableName, string keyFieldName) { QueryConditionNode conditions = new QueryConditionNode((QField)keyFieldName, Conditions.Equal, (QConst)fileObject.Name); Hashtable recordData = new Hashtable(); int result = Dalc.RecordsCount(new Query(tableName, conditions)); if (result > 0) { if (data.Contains(keyFieldName)) { data.Remove(keyFieldName); // fixed DB bug on update } Dalc.Update(new Query(tableName, conditions), data); } else { Dalc.Insert(tableName, data); } }