如何在没有给定 RavenDB 索引的情况下删除集合?
How to Delete Collection without given an index in RavenDB?
看到了查询删除集合实体的例子;
https://ravendb.net/docs/article-page/4.0/Csharp/client-api/operations/delete-by-query
但我的问题是,如何在不提供索引的情况下删除集合?
举个例子,我created/insert一个集合到RavenDB这样;
using (IDocumentSession session = _documentStore.OpenSession())
{
session.Store<TEntity>(entity);
session.SaveChanges();
}
我没有创建任何索引。只是将一些数据存储到 RavenDB。
我找了 api 这样的东西;
using (IDocumentSession session = _documentStore.OpenSession())
{
session.DeleteAll<TEntity>()
session.SaveChanges();
}
但这并不存在。那么如何在没有给定索引的情况下删除实体?
以下代码将 运行 直接在集合上而不需要创建索引:
var queryToDelete = new IndexQuery { Query = $"FROM {collection}" };
var operation = store.Operations.Send(new DeleteByQueryOperation(queryToDelete, new QueryOperationOptions { AllowStale = false }));
operation.WaitForCompletion(TimeSpan.FromSeconds(60));
看到了查询删除集合实体的例子;
https://ravendb.net/docs/article-page/4.0/Csharp/client-api/operations/delete-by-query
但我的问题是,如何在不提供索引的情况下删除集合?
举个例子,我created/insert一个集合到RavenDB这样;
using (IDocumentSession session = _documentStore.OpenSession())
{
session.Store<TEntity>(entity);
session.SaveChanges();
}
我没有创建任何索引。只是将一些数据存储到 RavenDB。 我找了 api 这样的东西;
using (IDocumentSession session = _documentStore.OpenSession())
{
session.DeleteAll<TEntity>()
session.SaveChanges();
}
但这并不存在。那么如何在没有给定索引的情况下删除实体?
以下代码将 运行 直接在集合上而不需要创建索引:
var queryToDelete = new IndexQuery { Query = $"FROM {collection}" };
var operation = store.Operations.Send(new DeleteByQueryOperation(queryToDelete, new QueryOperationOptions { AllowStale = false }));
operation.WaitForCompletion(TimeSpan.FromSeconds(60));