Hi,
i'm trying out the new v3 in a Xamarin.Forms project.
When i try to insert a new object into a new collection i get this error message:
Unhandled Exception:
System.ArgumentException: Can only unbox from an object or interface type to a value type.
at System.Linq.Expressions.Expression.Unbox (System.Linq.Expressions.Expression expression, System.Type type) [0x00051] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs:678
at LiteDB.Reflection.CreateGenericSetter (System.Type type, System.Reflection.MemberInfo memberInfo) [0x00086] in <69119786c28e4052b478158c5831f742>:0
at LiteDB.BsonMapper.BuildEntityMapper (System.Type type) [0x0010e] in <69119786c28e4052b478158c5831f742>:0
at LiteDB.BsonMapper.GetEntityMapper (System.Type type) [0x00031] in <69119786c28e4052b478158c5831f742>:0
at LiteDB.BsonMapper.SetAutoId (System.Object entity, LiteDB.LiteCollection1[T] col) [0x0003e] in <69119786c28e4052b478158c5831f742>:0 at LiteDB.LiteCollection1[T].Insert (T document) [0x0003c] in <69119786c28e4052b478158c5831f742>:0
It doesn't matter if i only insert one object or a list of objects.
Ok, I know where is it.
https://github.com/mbdavid/LiteDB/blob/master/LiteDB/Mapper/Reflection/Reflection.cs#L86
I change to support structs but not working as expected. Just remove this line (use var castTarget = Expression.Convert(target, type);)
I will fix later.
Works for me now.
Can you update nuget package with this patch, please?
yes @vkocjancic, will be "beta-2", but only this weekend because i'm out of office this week.
Ok, it's now published