public void UpdateSubChild(SubEntityId childId, string name, Guid correlationId)
        {
            // logic to manipulate child entities ALWAYS goes through the aggregate root
            var entity = GetAggregateEntity <SubEntityId, SubChildEntityTest>(childId);

            entity.Update(name, correlationId);
        }
Exemple #2
0
 public void AddChild(SubEntityId subEntityId, string name, Guid correlationId)
 {
     //This is the second way of setting entity relationships; namely passing the parent in the ctor.
     // While this is supported, as you can see, it looks strange. It is useful in situation where the
     // reference is actually kept and used later. It is also useful in situations where we do not want
     // the overhead of caching event published, since if we setup entity relationships, they go directly
     // to the aggregate.
     new SubChildEntityTest(this, subEntityId, name, correlationId);
 }
        public void AddSubChild(EntityId parentId, SubEntityId subEntityId, string name, Guid correlationId)
        {
            EntityTest parent;

            if (TryGetEntity(parentId, out parent))
            {
                parent.AddChild(subEntityId, name, correlationId);
            }
            else
            {
                throw new EntityNotFoundException(parentId.ToString(), typeof(EntityTest));
            }
        }
Exemple #4
0
        public SubChildEntityTest GetOrAdd(SubEntityId id, Func <SubEntityId, SubChildEntityTest> factory)
        {
            SubChildEntityTest entity;

            if (!SubEntities.TryGetValue(id, out entity))
            {
                entity = factory(id);

                SubEntities.Add(id, entity);
            }

            return(entity);
        }