You can create your query outside of DatabaseCommands IndexQuery and use Query.ToString () to populate the Query IndexQuery string, as shown below:
var query = session.Advanced.LuceneQuery<Asset, AssetsByExpirationDate>()
.WhereBetween("ExpirationDate",DateTime.MinValue,new DateTime(2012, 6, 1));
var queryString = query.ToString();
session.Advanced.DatabaseCommands.DeleteByIndex(typeof(AssetsByExpirationDate).Name, new IndexQuery
{
Query = queryString
});
Using this method, and if you are not very familiar with the lucene query syntax, the RavenDb Query API will build it for you as shown above by calling .ToString () and getting the next query string in Lucene format.
ExpirationDate:{00010101000000000 TO 20120601000000000}
, DatabaseCommands . lucene , Session.Delete() foreach.
var query = session.Advanced.LuceneQuery<Asset, AssetsByExpirationDate>()
.WhereBetween("ExpirationDate",DateTime.MinValue,new DateTime(2012, 6, 1));
var assets = query.ToList();
foreach(var asset in assets)
{
session.Delete<Asset>(asset);
}
session.SaveChanges();
, Ravendb 128 .