New Posts New Posts RSS Feed: A column that should not be persisted
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

A column that should not be persisted

 Post Reply Post Reply
Author
agrogers View Drop Down
Groupie
Groupie
Avatar

Joined: 11-Mar-2010
Posts: 41
Post Options Post Options   Quote agrogers Quote  Post ReplyReply Direct Link To This Post Topic: A column that should not be persisted
    Posted: 27-Jul-2010 at 10:56pm
Hi

We have been looking at the 'Source Access Type' (pg 74) property.  We have a 'Tag' field in many tables which we use to track selected records.  I understand the SourceAccessType property will stop modified fields from being written back to the database.  This is exactly what we need.

However, the documentation does not state that changing this property leaves dirty state of the record unchanged.  We dont want to write back records to the DB that have simply had their Tag property changed.  I would guess that it would not since we are not writing the property back.  But I just wanted to confirm that.

Thanks
Andrew
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 2:13pm
Why does it have to be a database column? Simply add a property to your object.

public string Tag
{
    get;
    set;
}
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 4:05pm

A  SourceAccessType of ReadOnly will stop DevForce from writing that property to the database on an insert or update.  The record is still considered modified though, so when PM.SaveChanges() is called the entity will be part of the save list.  If that’s not wanted then these entities can be stripped out of the list passed to SaveChanges, or they can be removed from the list via the PM.Saving event.

Back to Top
agrogers View Drop Down
Groupie
Groupie
Avatar

Joined: 11-Mar-2010
Posts: 41
Post Options Post Options   Quote agrogers Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 5:09pm
Originally posted by smi-mark

Why does it have to be a database column? Simply add a property to your object.

public string Tag
{
    get;
    set;
}

I think this is the best way for us to move forward on this one.   Will see how it goes.  Thanks.
Back to Top
agrogers View Drop Down
Groupie
Groupie
Avatar

Joined: 11-Mar-2010
Posts: 41
Post Options Post Options   Quote agrogers Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 5:51pm
Originally posted by davidklitzke

A  SourceAccessType of ReadOnly will stop DevForce from writing that property to the database on an insert or update.  The record is still considered modified though, ...



Thanks for clarifying this David.  I am not sure that the extra work to exclude those records that are not dirty is worth our while at present.  Will need to investigate it further. 

Our scenario means that the Tag property of 1000s of records could be touched (and touched often) with none of those records every actually being modified.  With SourceAccessType of the Tag column set to readonly we would be writing back to the DB 1000s of identical records ... not really what we want to do.

Is there a reason that a change to a column that is never persisted stills triggers a persist to the DB?  That doesnt seem right to me.

Thanks
Andrew
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down