mbdavid on vNext
add test Fixes #1980 Also add collaction in Bson.Com… and 2 more (compare)
db.UserVersion
to determine whether the file has to be processed or not
db.GetCollection<Setting>("settings").UpdateMany(s => new { setting.Name, setting.Value }, s => s.Name == setting.Name);
Extend expression must return an anonymous class to be merge with entities. Eg: col.UpdateMany(x => new { Name = x.Name.ToUpper() }, x => x.Age > 10)
BsonMapper.Global.EnumAsInteger = true;
to my application. That solved the problem with my "first" enum but introduced one for another enum I use. This enum is defined on my class as public DocumentType[] SupportedDocumentTypes { get; set; }
: 'Object cannot be stored in an array of this type.'
. Contents of the DB field at the point is : [0,1]
public BsonDocument AsDocument => this as BsonDocument;
BsonValue
into a BsonDocument
that I'm not seeing?
BsonValue
by doing new BsonValue(myBsonDocument)
and it is throwing a null exception on case BsonType.Document: return this.AsDocument.GetBytesCount(recalc);
during the upsert.
To be clear, the issue I'm seeing is that the above code is trying to cast the BsonValue
as a BsonDocument
....which I don't see how that would ever work. To answer your question:
The BsonDocument
passed to the BsonValue
is created like so:
BsonDocument ToBsonDocument()
{
BsonDocument retVal = new BsonDocument();
retVal["x"] = x;
retVal["y"] = y;
return retVal;
}
System.NotSupportedException: BSON type not supported
BsonMapper.Global.RegisterType<LogEvent>(
serialize: (LogEvent) => new BsonValue(JsonConvert.SerializeObject(LogEvent)),
deserialize: (BsonValue) => JsonConvert.DeserializeObject<LogEvent>(BsonValue.AsString, new LogEventJsonConverter(), new LogEventPropertyValueConverter())
);
LogEvent
to a BsonValue
containing a string. While this is supported (and even useful in some instances), you won't be able to have LogEvent
as the top-level object in a collection, you would only be able to use it as a sub-object.
BsonValue
s like string or int, you can only insert BsonDocument
s in a collection
BsonMapper.Global.RegisterType<LogEvent>(
serialize: (LogEvent) => LiteDB.JsonSerializer.Deserialize(JsonConvert.SerializeObject(LogEvent)),
deserialize: (BsonValue) => JsonConvert.DeserializeObject<LogEvent>(BsonValue.AsDocument.ToString(), new LogEventJsonConverter(), new LogEventPropertyValueConverter())
);
Delete<T>(T Entity, string collectionName)
or DeleteMany<T>(IEnumerable<T> entities, string collectionName)
as input. My class handles passing entities through to the LiteRepository but does not know anything about the entities passed in, so I can not get the id to pass in or to create a predicate. Is there a way to pass in an entity to be deleted?
Need your help on deserializing a List.
i create dynamically a query and get the result like this:
var resultSet = _store.Execute(sql).ToEnumerable().Select(s => BsonMapper.Global.Deserialize<SongData>(s)).ToList();
In my SongData class i have:
public List<string> PictureHashList => _pictureHashList;
Using LiteDBStudio i can see that i have values in the list, but the above query returns an empty list.
Any ideas?