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"))