本文整理汇总了C#中IAggregateRoot类的典型用法代码示例。如果您正苦于以下问题:C# IAggregateRoot类的具体用法?C# IAggregateRoot怎么用?C# IAggregateRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAggregateRoot类属于命名空间,在下文中一共展示了IAggregateRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PersistUpdateOf
public void PersistUpdateOf(IAggregateRoot entity)
{
Account account = entity as Account;
string sql = "UPDATE Account SET [email protected] WHERE [email protected]";
SqlParameter parameter1 = new SqlParameter("@Id", account.Id);
SqlParameter parameter2= new SqlParameter("@Balance", account.Balance);
using (SqlConnection conn = new SqlConnection(_connStr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sql;
cmd.Parameters.Add(parameter1);
cmd.Parameters.Add(parameter2);
int affectedCount = cmd.ExecuteNonQuery();
if (affectedCount <= 0)
{
throw new Exception("update Account failed");
}
}
}
}
示例2: RegisterUpdate
public void RegisterUpdate(IAggregateRoot aggregateRoot, IUnitOfWorkRepository repository)
{
if (!_updatedAggregates.ContainsKey(aggregateRoot))
{
_updatedAggregates.Add(aggregateRoot, repository);
}
}
示例3: UserSnapshot
public UserSnapshot(IAggregateRoot root, string name, int age)
{
Id = root.Id;
Version = root.Version;
Name = name;
Age = age;
}
示例4: RegisterNew
public void RegisterNew(IAggregateRoot entity, IUnitOfWorkRepository unitOfWorkRepository)
{
if (!addedEntities.ContainsKey(entity))
{
addedEntities.Add(entity, unitOfWorkRepository);
}
}
示例5: RegisterRemoved
public void RegisterRemoved(IAggregateRoot entity, IUnitOfWorkRepository unitOfWorkRepository)
{
if (!deletedEntities.ContainsKey(entity))
{
deletedEntities.Add(entity, unitOfWorkRepository);
}
}
示例6: Add
public void Add(IAggregateRoot entity, IUnitOfWorkRepository uowRepository)
{
if (!_addedEntities.ContainsKey(entity))
{
_addedEntities.Add(entity, uowRepository);
}
}
示例7: RegisterAmended
public void RegisterAmended(IAggregateRoot objectEntity, IUnitOfWorkRepository unitOfWorkRepository)
{
if (!changedEntities.ContainsKey(objectEntity))
{
changedEntities.Add(objectEntity, unitOfWorkRepository);
}
}
示例8: RegisterRemoved
public void RegisterRemoved(IAggregateRoot objectEntity, IUnitOfWorkRepository unitOfWorkRepository)
{
if (!removedEntities.ContainsKey(objectEntity))
{
removedEntities.Add(objectEntity, unitOfWorkRepository);
}
}
示例9: AggregateChangedEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="AggregateChangedEventArgs"/> class.
/// </summary>
/// <param name="aggregateRoot">The aggregate root.</param>
/// <param name="entity">The entity.</param>
/// <param name="propertyName">Name of the property.</param>
/// <param name="oldValue">The old value.</param>
/// <param name="newValue">The new value.</param>
public AggregateChangedEventArgs(
IAggregateRoot aggregateRoot,
IEntity entity,
string propertyName,
object oldValue,
object newValue )
{
if ( aggregateRoot == null )
{
throw new ArgumentNullException ( "aggregateRoot" );
}
if ( entity == null )
{
throw new ArgumentNullException ( "entity" );
}
if ( string.IsNullOrWhiteSpace ( propertyName ) )
{
throw new ArgumentNullException ( "propertyName" );
}
AggregateChangedType = AggregateChangedType.PropertyValueChanged;
AggregateRoot = aggregateRoot;
SourceEntity = entity;
PropertyName = propertyName;
OldValue = oldValue;
NewValue = newValue;
}
示例10: Add
public void Add(IAggregateRoot aggregateRoot)
{
if (!_aggregateRoots.ContainsKey(aggregateRoot.AggregateRootId))
{
_aggregateRoots.TryAdd(aggregateRoot.AggregateRootId, aggregateRoot);
}
}
示例11: RegisterDeletion
public void RegisterDeletion(IAggregateRoot aggregateRoot, IUnitOfWorkRepository repository)
{
if (!_deletedAggregates.ContainsKey(aggregateRoot))
{
_deletedAggregates.Add(aggregateRoot, repository);
}
}
示例12: Handle
public void Handle(IAggregateRoot root, IDomainEvent ev)
{
MethodInvoker invoker;
if (!_handlers.TryGetValue(ev.GetType(), out invoker))
{
throw new InvalidOperationException(string.Format("Apply method for event [{0}] wasn't resolved in [{1}]", ev.GetType().Name, root.GetType().Name));
}
invoker.Invoke(root, new object[] {ev});
}
示例13: CreateMessage
private DomainEventStreamMessage CreateMessage(IAggregateRoot aggregateRoot)
{
return new DomainEventStreamMessage(
ObjectId.GenerateNewStringId(),
aggregateRoot.UniqueId,
aggregateRoot.Version + 1,
aggregateRoot.GetType().FullName,
aggregateRoot.GetChanges(),
new Dictionary<string, string>());
}
示例14: RegisterNew
public void RegisterNew(IAggregateRoot entity, IUnitOfWorkRepository repository)
{
List<IAggregateRoot> items = null;
if (!add.TryGetValue(repository, out items))
{
items = new List<IAggregateRoot>();
add.Add(repository, items);
}
items.Add(entity);
}
示例15: BuildEventStream
private EventStreamRecord BuildEventStream(IAggregateRoot aggregateRoot, string commandId)
{
return new EventStreamRecord()
{
AggregateRootId = aggregateRoot.AggregateRootId,
CommandId = commandId,
Version = aggregateRoot.Version,
EventDatas = _binarySerializer.Serialize(aggregateRoot.GetUnCommitEvents())
};
}