public class CharacterTraits
{
[BsonId]
public int Index { get; set; }
public uint CharacterId { get; set; }
public uint TraitId { get; set; }
public SpoilerLevel SpoilerLevel { get; set; }
}
I then have a List<CharacterTraits> characterTraitsList = new List<CharacterTraits>();
with multiple elements in it. But when I run the following command (dbCharTraits.InsertBulk(CharacterTraitsList);
), I get the following error.
Hi! I've got a question about performance - I am using FindByOne
method on my collection, but it seems like it takes some to load the document from the database. Here's my F# implementation of GetById
repository
member this.GetById (id: string): 'a option =
let mapper = FSharpBsonMapper()
use db = new LiteDatabase(connectionString, mapper)
let collection = db.GetCollection<BsonDocument>(collectionName)
let queryResult = collection.FindById (BsonValue(id))
Option.fromBson queryResult
As I understood, _id
is indexed automatically so it should be rather fast, isn't it? My DB file on the disc has approx. 30MB.
I just want to understand what happens that it's slow :-) I would appreciate any help/clarification
\\
in position 7."}
I did find a workaround though. If I add a private constructor with no parameter it works... That way nobody can call that constructor from outside so my entity integrity is kept. However I feel a bit weird with that though... The real solution would be to create my own mappers that will map to a the LiteDB entity version of the entity and use those in my Repository. Like that I won't touch the object itself, that should be kept pure in its app context regardless its repository DB type.
Any thoughts? Am I missing something that is already built-in?
Eg: Some like this: col.Find(x => x.CustomerName == "John") must be converted to col.Find(Query.EQ("CustomerName", "John"))
SELECT $ FROM post
INCLUDE categories,tags
where ANY( $.Categories[*].$id = 7)
but getting > Left expression MAP($.Categories[*]=>@.$id)
returns more than one result. Try use ANY or ALL before operant.
Hi, we have a service web API application that we're developing that runs on multiple platforms but over the holiday period our testers have found an issue when the service has been left running on linux (CentOS based system). When using the application there is a database call using shared mode and on opening the database it's throwing IOException on the global mutex.
Is there something I need to be doing to handle this situation (mutext has timed out or something?)
System.IO.IOException: The system cannot open the device or file specified. : 'Global\\A4BC81403E0F366B89A06D796FC65AC91A2AEF11.Mutex'
at System.Threading.Mutex.CreateMutexCore(Boolean initiallyOwned, String name, Boolean& createdNew)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
at LiteDB.SharedEngine..ctor(EngineSettings settings)
at LiteDB.ConnectionString.CreateEngine()
at LiteDB.LiteDatabase..ctor(ConnectionString connectionString, BsonMapper mapper)
at LiteDB.LiteDatabase..ctor(String connectionString, BsonMapper mapper)
Construction of LiteDatabase is effectively via this code...
using (var db = new LiteDatabase("filename=database.db;Connection=shared;ReadOnly=true") { UtcDate = true })
{
// do work
}
Hello, I wonder if it's safe to read a collection at the same time than another collection is being written to (the file is opened in shared mode) ?
@ju2pom Based on my understanding, it's safe to read and write to the same collection at the time using LiteDb. But I would suggest not to use "Shared" connection string though, I ran into some problem trying to do so in one of my projects. I solved it by using a Singleton repo layer for my app.
Hello, I wonder if it's safe to read a collection at the same time than another collection is being written to (the file is opened in shared mode) ?
@ju2pom Based on my understanding, it's safe to read and write to the same collection at the time using LiteDb. But I would suggest not to use "Shared" connection string though, I ran into some problem trying to do so in one of my projects. I solved it by using a Singleton repo layer for my app.
Thanks @jeeshenlee_twitter for your answer, sadly I can't use the Direct mode because I have also two processes accessing the same database.