我有一组实体,它们都是从抽象类派生的
public abstract class NamedEntity : INamedEntity
{
#region Public Properties
public string Description { get; set; }
public string Id { get; set; }
public string Name { get; set; }
#endregion
}
当我持久化所有实体时,我想将Name
字段用作键,因此我覆盖DocumentKeyGenerator
并提供了这样的实现:
store.Conventions.DocumentKeyGenerator = entity =>
{
var namedEntity = entity as NamedEntity;
if (namedEntity != null)
{
return string.Format("{0}/{1}", store.Conventions.GetTypeTagName(entity.GetType()), namedEntity.Name);
}
return string.Format("{0}/", store.Conventions.GetTypeTagName(entity.GetType()));
};
当我第一次持久化实体列表时它工作正常,但如果我想再次持久化它们,我会遇到异常
PUT attempted on document 'xxxxx' using a non current etag
我刚开始使用 RavenDB,所以我不明白我做错了什么?