/// <summary> /// Update the identity property with the value from the supplied <see cref="SqlResult"/> /// instance. The identity property must be a single integer value for this to work. The /// identity property is the one holding the PrimaryKey attribute with the AutoGenerated /// value set to true. /// </summary> /// <param name="obj">The object instance whose identity should be set</param> /// <param name="identity">The row identity (i.e. the LastRowId property of SqlResult)</param> public void SetIdentity(object obj, int identity) { Check.VerifyEquals(type, obj.GetType(), "ObjectMap for {0} cannot set identity on {1}.", type, obj.GetType()); Check.VerifyNotNull(IdentityMap, Error.NullIdentity, type); object tmp = Convert.ChangeType(identity, IdentityMap.Type); IdentityMap.SetValue(obj, tmp); }