Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
inputfalken committed May 27, 2024
1 parent 4065bf6 commit fa01a53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public class ProductRepository
_queryByPrice = Product.QueryByPrice
.OnTable(tableName)
.WithKeyConditionExpression((db, arg) => $"{db.Price} = {arg}")
.ToQueryRequestBuilder()
.ToQueryRequestBuilder()
with
{
IndexName = Product.PriceIndex
};
{
IndexName = Product.PriceIndex
};
}

public async Task<IReadOnlyList<Product>> SearchByPrice(decimal price)
Expand Down Expand Up @@ -119,16 +119,15 @@ public class ProductRepository
}

// 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,
string Description,
Product.MetadataEntity Metadata
)
Product.MetadataEntity Metadata)
{
public const string PriceIndex = "PriceIndex";

Expand Down
3 changes: 1 addition & 2 deletions samples/Repository/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public partial record Product(
[property: DynamoDBHashKey, DynamoDBGlobalSecondaryIndexRangeKey(Product.PriceIndex)] string Id,
[property: DynamoDBGlobalSecondaryIndexHashKey(Product.PriceIndex)] decimal Price,
string Description,
Product.MetadataEntity Metadata
)
Product.MetadataEntity Metadata)
{
public const string PriceIndex = "PriceIndex";

Expand Down
6 changes: 5 additions & 1 deletion src/Dynatello/Builders/QueryRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ internal QueryRequestBuilder(Func<T, IAttributeExpression> attributeExpressionSe
TableName = tableName;
}

/// <summary>
///
/// </summary>
[Obsolete(Constants.ObsoleteConstructorMessage, true)]
public QueryRequestBuilder()
{
Expand Down Expand Up @@ -80,6 +83,7 @@ public QueryRequest Build(T arg)

if (Limit is { } limit)
queryRequest.Limit = limit;
else

if (IndexName is not null)
queryRequest.IndexName = IndexName;
Expand All @@ -89,4 +93,4 @@ public QueryRequest Build(T arg)

return queryRequest;
}
}
}

0 comments on commit fa01a53

Please sign in to comment.