Litedb: Deleting a doc from a LiteCollection causes a NullReferenceException.

Created on 28 Nov 2016  路  3Comments  路  Source: mbdavid/LiteDB

I'm building a web-service using LiteDB that runs on Mono and Ubuntu, and whenever I try to delete a record I get the following NullReferenceException.

System.NullReferenceException: Object reference not set to an instance of an object
at LiteDB.IndexService+c__Iterator0.MoveNext () [0x000f3] in /home/rstat1/Apps/third_party/LiteDB/Lit
eDB/Engine/Services/IndexService.cs:215
at System.Linq.Buffer1[TElement]..ctor (System.Collections.Generic.IEnumerable1[T] source) [0x00083] in /tmp/buildd/mono-4.6.2.7/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs:2594
at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00011] in /tmp/buildd/mono-4.6.2.7/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs:856
at LiteDB.LiteEngine+c__AnonStorey7.<>m__0 (LiteDB.CollectionPage col) [0x00080] in /home/rstat1/Apps/third_party/LiteDB/LiteDB/Engine/Engine/Delete.cs:24

I can also reproduce this on Windows Server 2016 and .NET 4.6. This error is occuring on the latest just built-from-the-master-branch version.

(sorry about the poor formatting, it was copied of a chrome dev-tools window, because I haven't spent much time on error reporting just yet)

bug

Most helpful comment

Hi guys, thanks! Fixed. The problem was in delete from a non _id field query (thats why Query.All works)

All 3 comments

Same here. Delete throws Null exception if a specific predicate is given.

// These two lines are from different parts of the code, they are not executed respectively
col.Delete(x => x.Name.StartsWith("Jo")); // Null exception.  
col.Delete(Query.All()); // No Exception.

Hi guys, thanks! Fixed. The problem was in delete from a non _id field query (thats why Query.All works)

Can confirm. Issue is now resolved. Thank you :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

furesoft picture furesoft  路  4Comments

GW-FUB picture GW-FUB  路  3Comments

RealBlazeIt picture RealBlazeIt  路  3Comments

ghiboz picture ghiboz  路  4Comments

sandolkakos picture sandolkakos  路  3Comments