Skip to content
Permalink
Browse files

refactor(IsNew): check string type PrimaryKey first #538 (#542)

* refactor(IsNew): check string type PrimaryKey first #538

#Issue
link #538

* doc: change file endings
  • Loading branch information...
ArgoZhang authored and pleb committed Aug 2, 2019
1 parent aa73080 commit 401c49ef109d1f4d6e618344dc505f0a38f81c19
Showing with 2 additions and 3 deletions.
  1. +2 −3 PetaPoco/Database.cs
@@ -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))

0 comments on commit 401c49e

Please sign in to comment.
You can’t perform that action at this time.