我在Dynamo Db中创建了一个表,其中Id作为主键,customerID作为排序键。
当我按如下所示的Id查询一个项时,我得到了错误“提供的键元素与模式不匹配”
var db = new PocoDynamo(awsDb);db.GetItem("aa4f0371-6144-4bd9-8980-5066501e37aa");
当我从发电机数据库中删除sortkey时,它按预期工作。
按Id获取项的正确方法是什么,Id也有一个与之关联的排序键。
public class Notification
{
[PrimaryKey]
public Guid Id { get; set; }
[RangeKey] //Sort Key
public Guid CustomerId { get; set; }
public Guid LinkId { get; set; }
public string PreviewText { get; set; }
}发布于 2019-05-16 15:24:17
在PocoDynamo中,您可以使用[CompositeKey]属性执行specify both Hash Key and Range Key,例如:
[CompositeKey(nameof(Id), nameof(CustomerId))]
public class Notification
{
public Guid Id { get; set; }
public Guid CustomerId { get; set; }
public Guid LinkId { get; set; }
public string PreviewText { get; set; }
}https://stackoverflow.com/questions/56162258
复制相似问题