querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

InsertGetId<T>() throws TargetParameterCountException

Open matteoiurato opened this issue 4 years ago • 4 comments

With SqliteCompiler, when calling: int insertedRowId = queryFactory.Query(TableName).InsertGetId<int>(data);

with data being a: Dictionary<string, object> a System.Reflection.TargetParameterCountException is thrown on:

function: private Dictionary<string, object> BuildDictionaryFromObject(object data, bool considerKeys = false) (Query.cs, line 369)

Thanks in advance for your help.

matteoiurato avatar Feb 19 '20 11:02 matteoiurato

is it related to #331 ? I think this problem has been solved and now is in nightly builds. -Edit: I have tried the latest Nightly build and the problem still exists.

hussamelvani avatar Feb 27 '20 13:02 hussamelvani

@matteoiurato @hussamelvani I tried the latest version 2.2.0 and everything is working as expected could you confirm please?.

ahmad-moussawi avatar Jun 10 '20 15:06 ahmad-moussawi

I've tried this on 2.2.0 and am getting this error too. Same conditions. The property it's failing on is System.Collections.Generic.IDictionary<System.String,System.Object>.Item

I'm passing in the ExpandoObject in my case, however, expando implements IDictionary, so also same scenario.

mrking avatar Jun 22 '20 10:06 mrking

An IDictionary<string, object> should be cast to IReadOnlyDictionary<string, object> in order to make use of the appropriate overload. Otherwise, the overload that accepts an object is used, which tries (and fails) to use the reflection to enumerate the data columns.

Leon99 avatar Jan 12 '21 04:01 Leon99