ravendb

Can NLog write to RavenDB database

帅比萌擦擦* 提交于 2019-12-11 05:41:45
问题 Want to try nosql and need to improve logging (write to some DB instead of files..). For now i use SQLCE for that. Can i use NLog and write to RavenDB for example? If 'yes' please provide some sample NLog configuratoin file. Thank you. 回答1: Yes, you can do that, but you would have to write the appender that does this yourself, I don't think there is an OOTB appender for this. 来源: https://stackoverflow.com/questions/9390922/can-nlog-write-to-ravendb-database

When is a groupby query evaluated in RavenDB?

人走茶凉 提交于 2019-12-11 05:23:35
问题 I'm struggling with the behaviour of grouping using RavenDB and LuceneQuery. I was always under the impression that IEnumerable was only evaluated when calling ToArray(), etc. The following query was split into two parts for the sake of clarity. I would not expect the query to be evaluated until after ToArray() is called on totalledBalanceList, my expectation being that the grouping is done on the server across all of the data. However, the actual result depends on the number of items

Query list of sub documents with RavenDB

北城以北 提交于 2019-12-11 03:53:01
问题 Given the following object structure: public class Object { public string Id {get;set;} public List<SubObject> SubObjects {get;set;} } public class SubObject {get;set;} { public string Id {get;set;} public string Name {get;set;} } How would I structure a query to return a List of SubObject where Name.Contains("a") I feel like it should be straightforward but I'm really struggling with it. 回答1: Short answer, you don't. Documents in RavenDb are aggregate roots and you can't load part of an

RavenDB Catch 22 - Optimistic Concurrency AND Seeing Changes from Other Clients

自古美人都是妖i 提交于 2019-12-11 03:39:30
问题 With RavenDB, creating an IDocumentSession upon app start-up (and never closing it until the app is closed), allows me to use optimistic concurrency by doing this: public class GenericData : DataAccessLayerBase, IGenericData { public void Save<T>(T objectToSave) { Guid eTag = (Guid)Session.Advanced.GetEtagFor(objectToSave); Session.Store(objectToSave, eTag); Session.SaveChanges(); } } If another user has changed that object, then the save will correctly fail. But what I can't do, when using

RavenDB attachments

你说的曾经没有我的故事 提交于 2019-12-11 03:21:42
问题 I'm playing around with RavenDB and deleted few test documents that had attachments before I had any attachments handling, so I was wandering if they are still on the disk somewhere and how I can find them easily ?. Another question is: When document is deleted and it had an attachment, will the attachment get auto deleted? I have browsed through RavenDB Web UI (Server), but could not find attachments. Just in case, below is my add attachment code: _session.Advanced.DocumentStore

RavenDB query index with custom fields names

≯℡__Kan透↙ 提交于 2019-12-11 03:16:01
问题 I have collection of documents Message in RavenDB. Definition: class Message { string Content; Tag[] Tags; } class Tag { string Value; } And i have index: from doc in docs.Messages from docTagsItem in (IEnumerable<dynamic>)doc.Tags select new { Content = doc.Content, TagsValue = docTagsItem.Value } Here we have field with name TagsValue which isn't part of class Message, that's why i can't using Session.Query<Message>(indexName).Where(m=>m.TagsValue==tagValue) How should query this index from

How to use a reference type as a key in a document in RavenDB

蓝咒 提交于 2019-12-11 03:14:43
问题 I have a class that I want to use for a document key in RavenDB: public class DocumentKey { public string Namespace { get; set; } public string Id { get; set; } } I've also implemented the ITypeConverter (not the .NET one, the RavenDB-specific one) interface to convert from the reference type to a string (because in the database, the keys are all really just strings). Finally, I've added the implementation of ITypeConverter to the IDocumentStore implementation through the List<ITypeConverter>

Json fields order

萝らか妹 提交于 2019-12-11 03:07:04
问题 I have a model stored with RavenDB done in this way: public abstract class Animal { public string Id { get; set; } public int LegsNumber { get; set; } } public class Giraffe: Animal { public double NeckLength { get; set; } } In my MVC controller I query all the Giraffe and put the result in Json format in this way: return new JsonResult { JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.AllowGet, Data = DocumentSession.Query<Giraffe>() }; The output is something like [{"NeckLength":2

Raven-Studio Index is returning different results to C# LINQ Query

断了今生、忘了曾经 提交于 2019-12-11 02:55:19
问题 I am learning RavenDB (Build 2851, Version 2.5.0 / 6dce79a) from Beginning Raven 2.x and am finding that the Raven-Studio is not filtering correctly. I have a table of cities in my database, storing their populations, locations etc. I have added an index in the code, using this: public class Cities_ByPopulation : AbstractIndexCreationTask<City> { public Cities_ByPopulation() { this.Map = cities => from city in cities select new { Population = city.Population }; // Generates as this in the

RavenDB UseOptimisticConcurrency in Config?

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:53:03
问题 Is there a way to set optimistic concurrency to true in Raven.Server.exe.config? Or, can it somehow be applied at the database level? On RavenDB's site, I see a couple of mentions of setting UseOptimisticConcurrency = true, but it looks like it's at the session level within the code: public void Save<T>(T objectToSave) { using (IDocumentSession session = Database.OpenSession()) { session.Advanced.UseOptimisticConcurrency = true; // This is the setting Guid eTag = (Guid)session.Advanced