Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add IsNew() Support for PK of Type Guid #93

wants to merge 1 commit into from

2 participants


We had decorated our Entities with an IsNew() property, but then I saw that PetaPoco had a similar helper method on the Database class. However, the PetaPoco db.IsNew("Id", entity) did not detect an Guid.Empty as being new.

public bool IsNew()
    return Id == Guid.Empty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 27, 2011
  1. @tawman
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  PetaPoco/PetaPoco.cs
2  PetaPoco/PetaPoco.cs
@@ -1561,6 +1561,8 @@ public bool IsNew(string primaryKeyName, object poco)
return (int)pk == 0;
else if (type == typeof(uint))
return (uint)pk == 0;
+ else if (type == typeof(Guid))
+ return (Guid)pk == Guid.Empty;
// Create a default instance and compare
return pk == Activator.CreateInstance(pk.GetType());
Something went wrong with that request. Please try again.