Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize "Id" in DetermineAggregateIdMember #1129

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class Invoice
public int Version { get; set; }
}

public record BadCommand(Guid Id);
public record BadCommand(Guid XId);

public record InvoiceApproved;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ internal static MemberInfo DetermineAggregateIdMember(Type aggregateType, Type c
{
var conventionalMemberName = $"{aggregateType.Name}Id";
var member = commandType.GetMembers().FirstOrDefault(x =>
x.HasAttribute<IdentityAttribute>() || x.Name.EqualsIgnoreCase(conventionalMemberName));
x.HasAttribute<IdentityAttribute>() || x.Name.EqualsIgnoreCase(conventionalMemberName) || x.Name.EqualsIgnoreCase("Id"));

if (member == null)
{
Expand Down
24 changes: 12 additions & 12 deletions src/Persistence/Wolverine.Marten/IMartenOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ public static class MartenOps
/// <summary>
/// Return a side effect of storing the specified document in Marten
/// </summary>
/// <param name="document"></param>
/// <param name="documents"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static StoreDoc<T> Store<T>(T document) where T : notnull
public static StoreDoc<T> Store<T>(params T[] documents) where T : notnull
{
if (document == null)
if (documents == null)
{
throw new ArgumentNullException(nameof(document));
throw new ArgumentNullException(nameof(documents));
}

return new StoreDoc<T>(document);
return new StoreDoc<T>(documents);
}

/// <summary>
Expand Down Expand Up @@ -226,16 +226,16 @@ public void Execute(IDocumentSession session)

public class StoreDoc<T> : DocumentOp where T : notnull
{
private readonly T _document;
private readonly T[] _documents;

public StoreDoc(T document) : base(document)
public StoreDoc(params T[] documents) : base(documents)
{
_document = document;
_documents = documents;
}

public override void Execute(IDocumentSession session)
{
session.Store(_document);
session.Store(_documents);
}
}

Expand Down Expand Up @@ -286,11 +286,11 @@ public override void Execute(IDocumentSession session)

public abstract class DocumentOp : IMartenOp
{
public object Document { get; }
public object[] Documents { get; }

protected DocumentOp(object document)
protected DocumentOp(params object[] documents)
{
Document = document;
Documents = documents;
}

public abstract void Execute(IDocumentSession session);
Expand Down
Loading