Hello, I have one more issue for ya!!
In an example of UnitTest5.cs
If you have an underscore in the one of property values that form a composite Row key, for example:
...
protected override void OnModelCreating(TableStorageModelBuilder modelbuilder)
{
modelbuilder.Entity<Product>()
.HasKeys(pk => pk.Category, rk =>new { rk.Store, rk.ProductId})
// .HasKeys(pk => pk.Category,rk=>string.Format("{0}_{1}", rk.Store.ToLower(), rk.ProductId))
.ToTable("unittest5");
base.OnModelCreating(modelbuilder);
}
...
var cat = "test";
var ctx = new ProductContext();
ctx.Products.Add(new Product
{
ProductId = 1,
Name = "MyName",
ImageName = "atest",
Category = cat,
Description = "adsad",
Store = "test_abc",
});
ctx.SaveChangesAsync().Wait();
var products = (from f in ctx.Products
where f.Category == cat
select f).ToArray();
In the above example Store = "test_abc"
and ProductId = 1
, so now the RowKey becomes
test_abc__1
[because if KeySeparator property is not set, it uses __ (two underscores) as default].
However, after running the following statement,
var products = (from f in ctx.Products
where f.Category == cat
select f).ToArray();
this is the output I get
products[0].Store = "test"
products[0].ProductId = "abc__1"
instead of getting
products[0].Store = "test_abc"
products[0].ProductId = "1"
It somehow still uses the first underscore to de-construct the properties from a RowKey. It does that for PartitionKey as well. I have tried explicitly setting the KeySeparator = "|"
, it still won't split the property on KeySeparator value but only on first underscore.
Hope you can help. Thanks.