Skip to content

Commit

Permalink
refactor(IsNew): check string type PrimaryKey first #538
Browse files Browse the repository at this point in the history
#Issue
link #538
  • Loading branch information
ArgoZhang committed Aug 2, 2019
1 parent d0a08ba commit 90d6928
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions PetaPoco/Database.cs
Expand Up @@ -2528,11 +2528,10 @@ protected virtual bool IsNew(string primaryKeyName, PocoData pd, object poco)

var type = pk != null ? pk.GetType() : pi.PropertyType;

if (type == typeof(string))
return string.IsNullOrEmpty((string)pk);
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) || !type.IsValueType)
return pk == null;

if (type == typeof(string))
return string.IsNullOrEmpty((string) pk);
if (!pi.PropertyType.IsValueType)
return pk == null;
if (type == typeof(long))
Expand Down

0 comments on commit 90d6928

Please sign in to comment.