/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { var session = context.Session; var item = session.Query.Single(context.TryRemapKey(ItemKey)); GetEntitySet(context).Remove(item); }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { foreach (var key in Keys) { context.RegisterKey(context.TryRemapKey(key), false); } }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { if (prepareAction != null) { prepareAction.Invoke(context, arguments); } }
/// <summary> /// Gets the entity set involved into this operation. /// </summary> /// <param name="context">The operation context.</param> /// <returns>Entity set involved into this operation.</returns> public EntitySetBase GetEntitySet(OperationExecutionContext context) { var session = context.Session; var key = context.TryRemapKey(Key); var target = session.Query.Single(key); return((EntitySetBase)target.GetFieldValue(Field)); }
private void MapCompositeKey(OperationExecutionContext context) { // TODO: AY: Review this later var domain = context.Session.Domain; var nodeId = context.Session.StorageNodeId; var keyInfo = Key.TypeReference.Type.Key; var hierarchy = keyInfo.Hierarchy; if (hierarchy.Key.Fields.Count == 1 && !hierarchy.Key.Fields[0].IsEntity) { return; } var columnIndex = 0; var sourceTuple = Key.Value; var resultTuple = Tuple.Create(sourceTuple.Descriptor); var hasTemporaryComponentBeenFound = false; foreach (var keyField in hierarchy.Key.Fields) { if (keyField.Parent != null) { continue; } if (keyField.IsPrimitive) { resultTuple.SetValue(columnIndex, sourceTuple.GetValue(columnIndex)); columnIndex++; } else { var association = keyField.Associations.Last(); var componentKeyValue = Tuple.Create(association.TargetType.Key.TupleDescriptor); sourceTuple.CopyTo(componentKeyValue, columnIndex, keyField.MappingInfo.Length); var componentKey = Key.Create(domain, nodeId, association.TargetType.UnderlyingType, TypeReferenceAccuracy.BaseType, componentKeyValue); var componentKeyLength = componentKey.Value.Count; Key mappedKey; if (context.KeyMapping.TryGetValue(componentKey, out mappedKey)) { mappedKey.Value.CopyTo(resultTuple, 0, columnIndex, componentKeyLength); hasTemporaryComponentBeenFound = true; } else { componentKeyValue.CopyTo(resultTuple, 0, columnIndex, componentKeyLength); } columnIndex += componentKeyLength; } } if (hasTemporaryComponentBeenFound) { var result = Key.Create(domain, nodeId, Key.TypeReference.Type.UnderlyingType, TypeReferenceAccuracy.BaseType, resultTuple); context.AddKeyMapping(Key, result); } }
private void MapNewKey(OperationExecutionContext context) { var domain = context.Session.Domain; if (Key.IsTemporary(domain)) { var mappedKey = Key.Generate(context.Session, Key.TypeInfo); context.AddKeyMapping(Key, mappedKey); } }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { var session = context.Session; var domain = session.Domain; var key = context.TryRemapKey(Key); var type = domain.Model.Types[TypeName]; key = Key.Create(domain, session.StorageNodeId, type, TypeReferenceAccuracy.ExactType, key.Value); session.CreateOrInitializeExistingEntity(type.UnderlyingType, key); }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { var session = context.Session; var key = context.TryRemapKey(Key); var valueKey = context.TryRemapKey(ValueKey); var entity = session.Query.Single(key); var value = ValueKey != null?session.Query.Single(valueKey) : Value; entity.SetFieldValue(Field, value); }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { var session = context.Session; var entities = from key in Keys let remappedKey = context.TryRemapKey(key) let entity = session.Query.Single(remappedKey) select entity; session.Remove(entities); }
/// <inheritdoc/> /// <exception cref="VersionConflictException">Version check failed.</exception> protected override void ExecuteSelf(OperationExecutionContext context) { var session = context.Session; var entity = session.Query.Single(Key); if (entity.VersionInfo != Version) { if (OrmLog.IsLogged(LogLevel.Info)) { OrmLog.Info(Strings.LogSessionXVersionValidationFailedKeyYVersionZExpected3, session, Key, entity.VersionInfo, Version); } throw new VersionConflictException( string.Format(Strings.ExVersionOfEntityWithKeyXDiffersFromTheExpectedOne, Key)); } }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { if (context.KeyMapping.ContainsKey(Key)) { return; } var keyInfo = Key.TypeReference.Type.Key; if (!keyInfo.ContainsForeignKeys) { MapNewKey(context); } else { MapCompositeKey(context); } }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { // There should be no base method call here! context.RegisterKey(context.TryRemapKey(Key), true); }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { // Does nothing. }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { base.PrepareSelf(context); // Next line works properly when ValueKey==null context.RegisterKey(context.TryRemapKey(ValueKey), false); }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { GetEntitySet(context).Clear(); }
/// <inheritdoc/> protected override void ExecuteSelf(OperationExecutionContext context) { executeAction.Invoke(context, arguments); }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { base.PrepareSelf(context); context.RegisterKey(context.TryRemapKey(ItemKey), false); }
/// <inheritdoc/> protected override void PrepareSelf(OperationExecutionContext context) { context.RegisterKey(Key, false); }