The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

RowVersion entity.Save() Issue

Last post 03-10-2007, 10:44 AM by mrbluejello. 2 replies.
Sort Posts: Previous Next
  •  03-09-2007, 10:06 PM 938

    RowVersion entity.Save() Issue

    OK, so I'm using some code generation, building an assignment statement for every field, and I ran into a situation where my code updated my entity.RowVersion property, and no other property of my entity.  I assigned it its original value, however, this marked the entity's IsDirty = True.  So, when I called entity.Save(), it ran an update statement against the database and I got a SQL syntax error.  I checked the SQL Server Profile to see the SQL, and this is what it showed me...

     UPDATE [CSLATestBed].[dbo].[EditableRootItem] SET  WHERE ([Id] = @Id) AND [RowVersion] = @RowVersion

    It did not set any items in the SET clause because (I'm assuming), you never allow the RowVersion field (timestamp, SQL Server 2005) to be updated through EntitySpaces (makes sense), however if a developer mistakenly updates ONLY this field, you still mark the entity as dirty, thus leading to the SQL syntax issue.

    I have since altered my code so that the RowVersion field never gets assigned to, however, it might make sense to not allow the entity to be made dirty by the concurrency/timestamp field if the developer mistakenly updates it....  There is no logical reason for a developer to ever do this, but letting this current behavior stay the way this way is just a trap door waiting for someone to walk into it (in my opinion).

    Thoughts?

    Eric

  •  03-10-2007, 5:46 AM 943 in reply to 938

    Re: RowVersion entity.Save() Issue

    Yes, I think we need to make sure these have get's but no set's, however, in truth you shouldn't be trying to set those, however, let us see if we can sneak this in.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-10-2007, 10:44 AM 950 in reply to 943

    Re: RowVersion entity.Save() Issue

    Oh, I understand that they shouldn't be set to, I just was using code generation to (blindly) copy each field into a local member of my CSLA object, then before saving my object, copying each local member BACK to the entity.  RowVersion got caught up in the mix (because I was doing everything).  Now that I see the problems that causes, I don't do the assignment of RowVersion to the entity any more.  Will not having a set mess up any of your databinding stuff?  I'm not using your databinding because of the CSLA, so I'm not prepared to test this.
View as RSS news feed in XML