ravendb

Unit Testing RavenDB

我是研究僧i 提交于 2019-11-29 02:52:20
In my unit tests I am setting up each test to have a totally empty IDocumentSession. I do it like this: [SetUp] public void SetUp() { _store = new EmbeddableDocumentStore { RunInMemory = true }; _store.Initialize(); Session = _store.OpenSession(); } But I think this might be the reason my tests are a little slow. I was wondering if there is a simple command to delete all documents from the database. What I want is to know is: if I can do this, and if it would improve performance. This is the recommended approach for unit testing with ravendb The not recommended for production basically runs in

RavenDB fast substring search

你说的曾经没有我的故事 提交于 2019-11-29 02:27:41
I have perhaps trillions of string sequences. I'm looking for a fast substring search. I've created an index. When I am trying to get some results( x => x.StartWith ), it takes about 2 sec on a 3 million object database. How much time it might take on 500 million objects? Is it possible to have RavenDB search faster? store.DatabaseCommands.PutIndex("KeyPhraseInfoByWord", new Raven.Client.Indexes.IndexDefinitionBuilder<KeyPhraseInfo> { Map = wordStats => from keyPhraseInfo in keyPhraseInfoCollection select new { keyPhraseInfo.Key }, Analyzers = { { x => x.Key, "SimpleAnalyzer"} } }); Nier0, You

Linq query with multiple Contains/Any for RavenDB

旧时模样 提交于 2019-11-29 02:22:23
问题 I have a document class that contains a list of "tags". Something like: class Item { string Name { get; set; } List<string> Tags {get; set;} } Now I would like to create a query for RavenDB that hands me all items filtered by a list of tags. When using Entity Framework I managed to do this by something like this: var query = GetQueryable(); foreach (var tag in tags) { query = query.Where(i => i.Tags.Contains(tag)); } However, this doesn't seem to work with RavenDB, most likely because

How should stale indexes be handled during testing?

牧云@^-^@ 提交于 2019-11-29 00:54:05
问题 I am using RavenDB in In-Memory mode for unit testing. My queries are backed by static indexes. I am not using WaitForNonStaleResults() API (nor do I want to). Typical workflow for a test is: Initialise RavenDB in In-Memory mode Integrate indexes using IndexCreation.CreateIndexes(Assembly, IDocumentStore) Insert test data (for verifying query behaviour) Run query Verify query output I have noticed steps 1-3 happen so quickly, that static indexes don't have time to get updated before step 4 -

RavenDB: How to query with multiple search terms

会有一股神秘感。 提交于 2019-11-28 23:48:16
问题 My entity is: class Resource { string Name; string EmployeeId; } How do I query for resources of multiple employees? I tried this: Resource[] FindResourcesByEmployees(string[] employeeIds) { return this.Session.Query<Resource>() .Where(r => employeeIds.Contains(r.EmployeeId)) .ToArray(); } However that gives me NotSupportedException: Method not supported: Contains. Then I tried the following method: Resource[] FindResourcesByEmployees(string[] employeeIds) { return this.Session.Query<Resource

RavenDb : Force indexes to wait until not stale whilst unit testing

丶灬走出姿态 提交于 2019-11-28 20:24:36
When unit testing with RavenDb, it is often the case that newly added data is retrieved or otherwise processed. This can lead to 'stale index' exceptions e.g. Bulk operation cancelled because the index is stale and allowStale is false According to a number of answers How should stale indexes be handled during testing? WaitForNonStaleResults per DocumentStore RavenDb : Update a Denormalized Reference property value The way to force the database (the IDocumentStore instance) to wait until its indexes are not stale before processing a query or batch operation is to use DefaultQueryingConsistency

How would I model data that is heirarchal and relational in a document-oriented database system like RavenDB?

。_饼干妹妹 提交于 2019-11-28 19:20:08
问题 Document oriented databases (particularly RavenDB) are really intriguing me, and I'm wanting to play around with them a bit. However as someone who is very used to relational mapping, I was trying to think of how to model data correctly in a document database. Say I have a CRM with the following entities in my C# application (leaving out unneeded properties): public class Company { public int Id { get; set; } public IList<Contact> Contacts { get; set; } public IList<Task> Tasks { get; set; }

Proper Way to Retrieve More than 128 Documents with RavenDB

人盡茶涼 提交于 2019-11-28 17:03:45
I know variants of this question have been asked before (even by me), but I still don't understand a thing or two about this... It was my understanding that one could retrieve more documents than the 128 default setting by doing this: session.Advanced.MaxNumberOfRequestsPerSession = int.MaxValue; And I've learned that a WHERE clause should be an ExpressionTree instead of a Func, so that it's treated as Queryable instead of Enumerable. So I thought this should work: public static List<T> GetObjectList<T>(Expression<Func<T, bool>> whereClause) { using (IDocumentSession session = GetRavenSession(

RavenDB Map-Reduce Example using .NET Client

不问归期 提交于 2019-11-28 16:22:04
问题 I'm looking for an example of how to implement and use Map-Reduce within the RavenDB .NET Client. I'd like to apply it to a specific scenario: generating unique and total visitor counts. A sample document that would be stored within RavenDB: public class StatisticsEntry { public string Id { get; set; } public string UserId { get; set; } } I can figure out how to create a standard index using Map, but I'm lost as to how to actually use the Reduce function, and then retrieve the results.

Is it possible to connect to an embedded DB with Raven Management Studio

拥有回忆 提交于 2019-11-28 13:18:09
I'm playing with Raven DB and am wondering if it's possible to connect to an embedded DB with Raven Management Studio. Has anyone ever done this? If I understood you correct and you mean the Web UI, you simply have to enable the embedded web server. var documentStore = new EmbeddableDocumentStore { DataDirectory = "Data", UseEmbeddedHttpServer = true }; See http://ravendb.net/docs/server/deployment/embedded Also make sure to include Raven.Studio.xap in the root of your web application 来源: https://stackoverflow.com/questions/6947092/is-it-possible-to-connect-to-an-embedded-db-with-raven