Is it possible to use the following expression with LiteDB?
return maintenanceAssetCollection.UpdateMany(_ =>
new MaintainableAssetEntity()
{
AttributeDatumEntities = new List<IAttributeDatumEntity>(),
Id = _.Id,
LocationEntity = _.LocationEntity,
NetworkId = _.NetworkId
},
_ => _.NetworkId == networkId);
I keep getting a runtime NotSupported exception. When I change the list assignment to null it works.
Ah, I changed the code to this and it seemed to work:
return maintenanceAssetCollection.UpdateMany(_ =>
new MaintainableAssetEntity()
{
AttributeDatumEntities = new List<IAttributeDatumEntity>() { },
Id = _.Id,
LocationEntity = _.LocationEntity,
NetworkId = _.NetworkId
},
_ => _.NetworkId == networkId);
Note the curly brackets in the new list expression are the change.
Hi, I can not find any way to use expressions and functions: https://www.litedb.org/api/functions/ https://www.litedb.org/docs/expressions/
how can I do that?
suppose I have a collection CalledFinancialContractCollection
contains Contracts
public class FinancialContract : ReactiveObject, IHotHostReloaded<FinancialContract>
{
[BsonId] public ObjectId Id { get; set; }
public string PersonName { get; set; }
public string PersonIdNumber { get; set; }
public DateTime StartDate { get; set; }
}
How can I get the recent Contract with depends on StartDate
by using Functions | Expressions
The problem is i can not find anything in the documentation descripe how to use it, the only example is with indices
And take this example from expressions
page
SELECT { upper_titles: ARRAY(UPPER($.Books[*].Title)) } WHERE $.Name LIKE "John%"
How can i execute this from c# ??
Please Helpe me.
Hi everyone
I'm trying to use LiteDB (net45) in Unity 2019 targeting an ARM device. The sample application to perform CRUD operations works fine in the editor but in the device I'm getting this exception:
System.NotSupportedException: Invalid BsonExpression when converted from Linq expression: x => x.Name - `$.Name` ---> System.TypeInitializationException: The type initializer for 'LiteDB.BsonExpression' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: method
I did some googling and found a stack overflow question asking about this, in which the one answer states that this could be due to missing dependencies. However, I am using the .NETFramework 4.5 DLL which according to the NuGet page does not have any dependencies.
Has anyone faced this issue? If so can someone let me know how I can address this?
In LiteDB 5, what does the bool return value mean with Upsert on a LiteCollection? I can't find documentation saying what it does.
I'd normally assume false means it didn't apply changes, but on first call it inserts a document and returns true, and second call with document with same ID and different values, it updates the record but returns false.
I've got existing code that assumed true just meant success and if that's not the case I've got some bugs there. Although that was with LiteDB 4, and I'm migrating to 5.
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."}