C# RavenDB:在Raven 4.0中将自动增量添加到ID以外的其他属性

C# RavenDB:在Raven 4.0中将自动增量添加到ID以外的其他属性,c#,asp.net,ravendb,auto-increment,C#,Asp.net,Ravendb,Auto Increment,在4.0之前,我可以设置中提到的自动增量属性 但在4.0 IDocumentStoreListener中,HiLoKeyGenerator已被删除。然而,我可以捕捉到保存文档的事件,如。但无法生成增量ID。是否有解决方法 public class Product { public string Id {get; set;} public int OtherIncrementalId {get; set;} } 关于基于类型生成自定义id的

在4.0之前,我可以设置中提到的自动增量属性

但在4.0 IDocumentStoreListener中,HiLoKeyGenerator已被删除。然而,我可以捕捉到保存文档的事件,如。但无法生成增量ID。是否有解决方法

    public class Product 
    {
       public string Id {get; set;}
       public int OtherIncrementalId {get; set;} 
    }

关于基于类型生成自定义id的文档:

如果您想为我使用此工具尝试的所有类型自定义id生成,并且可以正常工作:

 documentStore.Conventions.RegisterAsyncIdConvention<object>((dbname, obj) =>
 {
    return Task.FromResult(DocumentConventions.DefaultGetCollectionName(obj.GetType())+"/"+ YourCustomFunctionToGetNextId());
 });