FromQueryAsync does not allow TableNamePrefix to be set #2614
-
Describe the bugQueryAsync allows TableNamePrefix but FromQueryAsync does not. Expected BehaviorExpected TableNamePrefix to be public on QueryOperationConfig class Current BehaviorTableNamePrefix is not present on QueryOperationConfig class Reproduction Stepsawait dynamoContext
.FromQueryAsync<TModel>(new QueryOperationConfig
{
IndexName = indexName,
TableNamePrefix = stackName
}) Possible SolutionAdd the property Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWSSDK.DynamoDBv2 3.7.103.8 Targeted .NET Platform.Net 6 Operating System and versionLambda |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
This appears to be a feature request since it is not breaking any functionality. Need to investigate on why the support for |
Beta Was this translation helpful? Give feedback.
-
It breaks deployment via cloud formation where you want to have a dev,
staging and production stack.
Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@BryanCrotaz Good afternoon. I'm unsure if you have tried to use the overloaded version of FromQueryAsync(QueryOperationConfig, DynamoDBOperationConfig) where you could provide using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;
using Amazon.DynamoDBv2.DocumentModel;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DynamoDBTest
{
class Program
{
private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();
static void Main(string[] args)
{
DynamoDBContext context = new DynamoDBContext(client);
Task.WaitAll(TestTableNamePrefix(context));
}
private static async Task TestTableNamePrefix(DynamoDBContext context)
{
try
{
int bookID = 1001; // Some unique value.
DigitalBook myBook = new DigitalBook
{
Id = bookID,
Title = "object persistence-AWS SDK for.NET SDK-Book 1001",
ISBN = "111-1111111001",
BookAuthors = new List<string> { "Author 1", "Author 2" },
ImageUrl = "http://localhost/test.jpg"
};
// Save the book.
await context.SaveAsync(
myBook,
new DynamoDBOperationConfig()
{
TableNamePrefix = "test_"
}
);
var search = context.FromQueryAsync<DigitalBook>(
new QueryOperationConfig()
{
IndexName = "Id-ISBN-index",
Filter = new QueryFilter("Id", QueryOperator.Equal, 1001)
},
new DynamoDBOperationConfig()
{
TableNamePrefix = "test_"
}
);
Console.WriteLine("items retrieved");
var searchResponse = search.GetRemainingAsync().Result;
searchResponse.ForEach((s) =>
{
Console.WriteLine(s.Title);
});
}
catch(Exception e)
{ Console.WriteLine(e.Message); }
}
}
[DynamoDBTable("ProductCatalog")]
public class Book
{
[DynamoDBHashKey] //Partition key
public int Id
{
get; set;
}
[DynamoDBProperty("title")]
public virtual string Title
{
get; set;
}
[DynamoDBProperty]
public string ISBN
{
get; set;
}
[DynamoDBProperty("Authors")] //String Set datatype
public List<string> BookAuthors
{
get; set;
}
}
[DynamoDBTable("DigitalProductCatalog")]
public class DigitalBook : Book
{
public override string Title
{
get;set;
}
[DynamoDBProperty]
public string ImageUrl
{
get; set;
}
}
} For above code, I have a DynamoDB table named "test_DigitalProductCatalog". Hence, I'm setting Thanks, |
Beta Was this translation helpful? Give feedback.
-
I haven’t tried it but that basically confirms this is a bug if you
have to use a more complex workaround.
Bryan Crotaz
|
Beta Was this translation helpful? Give feedback.
-
@BryanCrotaz Upon investigating further, looks like QueryAsync(object, DynamoDBOperationConfig) also supports specifying Please refer https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/DynamoDBv2/TDynamoDBContext.html for more details. Hence, this is neither a bug or a feature request, rather a guidance issue. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@BryanCrotaz Good afternoon. I'm unsure if you have tried to use the overloaded version of FromQueryAsync(QueryOperationConfig, DynamoDBOperationConfig) where you could provide
TableNamePrefix
in DynamoDBOperationConfig, but the following code works: