DapperLib/Dapper

explicitKey bug

Closed this issue · 5 comments

table using [explicitKey],first [update] then [insert], the [ExplicitKey] not insert.
guess: [update] keyProperties.AddRange(explicitKeyProperties);

Can you plese provide some more info @itlizhi ? What database platform? Can you give some sample code to reproduce the error?

using sqlserver 2008 r2 @johandanforth
20151201095158

Which version of Dapper and Dapper.Contrib? I actually got the same error as you with the current Nuget version 1.44. I'll see if I can find the same bug in the current source. Might be a bug actually.

package id="Dapper" version="1.42" targetFramework="net45"
package id="Dapper.Contrib" version="1.44" targetFramework="net45"

Thanks @itlizhi I think I found the problem yesterday and I will look at a fix this weekend. For some reason the ExplicitKey property is cached as an ordinary key in the Update extension method, which is wrong. That is why it works if Insert is called first. But I just had a glance at it yesterday, I'll look at it on saturday or sunday, unless someone beats me to it. It's easy to test and reproduce.