diff --git a/samples/Repository/Program.cs b/samples/Repository/Program.cs index af42634..550b2a6 100644 --- a/samples/Repository/Program.cs +++ b/samples/Repository/Program.cs @@ -38,11 +38,11 @@ public ProductRepository(string tableName, IAmazonDynamoDB amazonDynamoDb) _queryByPrice = Product.QueryByPrice .OnTable(tableName) .WithKeyConditionExpression((db, arg) => $"{db.Price} = {arg}") - .ToQueryRequestBuilder() + .ToQueryRequestBuilder() with - { - IndexName = Product.PriceIndex - }; + { + IndexName = Product.PriceIndex + }; } public async Task> SearchByPrice(decimal price) @@ -98,10 +98,10 @@ public async Task Create(Product product) } // These attributes is what makes the source generator kick in. Make sure to have the class 'partial' as well. -[DynamoDBMarshaller(typeof(Product), PropertyName = "Put")] -[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(string), PropertyName = "GetById")] -[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)), PropertyName = "UpdatePrice")] -[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(decimal), PropertyName = "QueryByPrice")] +[DynamoDBMarshaller(AccessName = "Put")] +[DynamoDBMarshaller(AccessName = "GetById", ArgumentType = typeof(string))] +[DynamoDBMarshaller(AccessName = "UpdatePrice", ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)))] +[DynamoDBMarshaller(AccessName = "QueryByPrice", ArgumentType = typeof(decimal))] public partial record Product( [property: DynamoDBHashKey, DynamoDBGlobalSecondaryIndexRangeKey(Product.PriceIndex)] string Id, [property: DynamoDBGlobalSecondaryIndexHashKey(Product.PriceIndex)] decimal Price, diff --git a/src/Dynatello/Dynatello.csproj b/src/Dynatello/Dynatello.csproj index 162a4db..cbc33d3 100644 --- a/src/Dynatello/Dynatello.csproj +++ b/src/Dynatello/Dynatello.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/tests/Dynatello.Tests/ToPutItemRequestTests.cs b/tests/Dynatello.Tests/ToPutItemRequestTests.cs index cca3cc3..3cca72c 100644 --- a/tests/Dynatello.Tests/ToPutItemRequestTests.cs +++ b/tests/Dynatello.Tests/ToPutItemRequestTests.cs @@ -8,7 +8,7 @@ namespace Dynatello.Tests; -[DynamoDBMarshaller(typeof(User))] +[DynamoDBMarshaller(EntityType = typeof(User))] public partial class ToPutItemRequestTests { private readonly Fixture _fixture = new(); @@ -139,4 +139,4 @@ public class UpdateUserEmail public string UserId { get; set; } = null!; public string UserEmail { get; set; } = null!; public DateTimeOffset TimeStamp { get; set; } -} \ No newline at end of file +} diff --git a/tests/Dynatello.Tests/ToQueryRequestTests.cs b/tests/Dynatello.Tests/ToQueryRequestTests.cs index f7064c2..b16cd21 100644 --- a/tests/Dynatello.Tests/ToQueryRequestTests.cs +++ b/tests/Dynatello.Tests/ToQueryRequestTests.cs @@ -100,17 +100,13 @@ public void Build_Request_FilterExpression() } } -[DynamoDBMarshaller(typeof(Cat), PropertyName = "QueryWithCuteness", - ArgumentType = typeof((Guid Id, double MinimumCuteness)))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeKey", ArgumentType = typeof((Guid Id, Guid HomeId)))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetById", ArgumentType = typeof(Guid))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByInvalidPartition", ArgumentType = typeof(string))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidPartition", - ArgumentType = typeof((string Id, Guid HomeId)))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidRange", - ArgumentType = typeof((Guid Id, string HomeId)))] -[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidPartitionAndRange", - ArgumentType = typeof((double Id, string HomeId)))] +[DynamoDBMarshaller(AccessName = "QueryWithCuteness", ArgumentType = typeof((Guid Id, double MinimumCuteness)))] +[DynamoDBMarshaller(AccessName = "GetByCompositeKey", ArgumentType = typeof((Guid Id, Guid HomeId)))] +[DynamoDBMarshaller(AccessName = "GetById", ArgumentType = typeof(Guid))] +[DynamoDBMarshaller(AccessName = "GetByInvalidPartition", ArgumentType = typeof(string))] +[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidPartition", ArgumentType = typeof((string Id, Guid HomeId)))] +[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidRange", ArgumentType = typeof((Guid Id, string HomeId)))] +[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidPartitionAndRange", ArgumentType = typeof((double Id, string HomeId)))] public readonly partial record struct Cat( [property: DynamoDBHashKey] Guid Id, [property: DynamoDBRangeKey] Guid HomeId, @@ -118,4 +114,4 @@ public readonly partial record struct Cat( double Cuteness) { public static readonly Fixture Fixture = new(); -} \ No newline at end of file +} diff --git a/tests/Dynatello.Tests/ToUpdateItemRequestTests.cs b/tests/Dynatello.Tests/ToUpdateItemRequestTests.cs index 4bd0f9b..f76a14f 100644 --- a/tests/Dynatello.Tests/ToUpdateItemRequestTests.cs +++ b/tests/Dynatello.Tests/ToUpdateItemRequestTests.cs @@ -7,8 +7,8 @@ namespace Dynatello.Tests; -[DynamoDBMarshaller(typeof(User))] -[DynamoDBMarshaller(typeof(User), PropertyName = "UpdateEmail", ArgumentType = typeof(UpdateUserEmail))] +[DynamoDBMarshaller(EntityType = typeof(User))] +[DynamoDBMarshaller(EntityType = typeof(User), AccessName = "UpdateEmail", ArgumentType = typeof(UpdateUserEmail))] public partial class ToUpdateItemRequestTests { private readonly Fixture _fixture = new(); @@ -210,4 +210,4 @@ static void Expected(User x, UpdateRequestBuilder builder) => UpdateExpression = "SET #Email = :p1, #Firstname = :p2" }); } -} \ No newline at end of file +}