After some digging, I was able to find the reason:
The following is a delegate to CreateParamInfoGenerator from dapper SqlMapper:
public static Action<IDbCommand, object> CreateParamInfoGenerator(Identity identity) {
Details is your unanimous parameter, which is ordered by OrderBy (p => p.Name), which moves the city forward.
new { firstName = "John", city = "SomeCity", lastName = "Smith" }
Then the details are added to the IDbCommand parameters, where the order is important.
If I comment on the OrderBy () clause, then everything will work.
I also tested DynamicParameters and intentionally reordered the attributes for moving around the city:
var parameters = new DynamicParameters(); parameters.Add("city", "SomeCity"); parameters.Add("firstName", "John"); parameters.Add("lastName", "Smith"); var result = dbConnection.Query<string>( "update Students set FirstName = @firstName, City = @city where LastName = @lastName", parameters );
The above did not work, so the order of the attributes is the reason!
I think you can now change your local copy of SqlMapper and remove OrderBy () and wait for the official sentence from Marc ...
Hope this helps.
Void ray
source share