【发布时间】:2012-10-07 20:48:29
【问题描述】:
我有一组实体,它们都是从抽象类派生的
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,所以我不明白我做错了什么?
【问题讨论】:
标签: c# nosql ravendb document-database