LiteDB icon indicating copy to clipboard operation
LiteDB copied to clipboard

FindAll() - Object inheritance and references seems to cause a problem?

Open digitalkirkley opened this issue 8 years ago • 4 comments

When starting up LiteDb, creating mappings, on one specific object type I keep getting an error/exception as below. The object has property references to other objects with property names that are the same. Is this the cause of this issue? (I also get this on EnsureIndex)

at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) at LiteDB.EntityMapper.get_Id() at LiteDB.LiteCollection1..ctor(String name, LazyLoad1 engine, BsonMapper mapper, Logger log) at LiteDB.LiteDatabase.GetCollection[T](String name)

digitalkirkley avatar Jun 15 '18 14:06 digitalkirkley

Hi, paste your code that are throwing this error to detect what going on

mbdavid avatar Jun 15 '18 18:06 mbdavid

I discovered what this was. When you define the unique ID via global entity mapper and also have a property on a base class named Id, LiteDb was holding both Unique Id members. I renamed the base class property which was named <base class name + Id> to something else and all is working fine. Maybe some validation would be good to indicate this scenario?

digitalkirkley avatar Jun 18 '18 08:06 digitalkirkley

Hi @digitalkirkley, I will check this. Each entity must have only one single "_id" field into document.

mbdavid avatar Jun 18 '18 11:06 mbdavid

Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks!

lbnascimento avatar Feb 28 '20 13:02 lbnascimento