codefluent

CodeFluentEntityState remains Unchanged


I have an entity with the following config:

  <cf:entity name="Statistic" _fr:fastReader="true" setType="List" concurrencyMode="None" trackingModes="None" namespace="Runtime" categoryPath="/Compareware" persistenceName="Statistic">
<cf:property name="Date" trackingModes="None" key="true" typeName="date" />
<cf:property name="ResultViews" trackingModes="None" typeName="short" />
<cf:property name="Position" cfps:size="8,4" cfps:dataType="numeric" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" trackingModes="None" typeName="float" />
<cf:property name="Detailviews" trackingModes="None" typeName="short" />
<cf:property name="Clicks" trackingModes="None" typeName="short" />
<cf:property name="CostTotalExclVat" cfps:size="8,2" cfps:dataType="numeric" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" trackingModes="None" typeName="decimal" />
<cf:property name="SiteGuid" trackingModes="None" typeName="guid" />
<cf:property name="FormsSent" defaultValue="0" trackingModes="None" typeName="short" />
<cf:property name="FormsAccepted" trackingModes="None" typeName="short" />
<cf:property name="ObjectGuid" trackingModes="None" key="true" />
<cf:property name="Reveals" trackingModes="None" typeName="short" />
<cf:property name="ClusterAccountGuid" trackingModes="None" typeName="guid" />
<cf:property name="EndDate" trackingModes="None" typeName="date" />
<cf:property name="FormsSentNeedingAcceptance" trackingModes="None" typeName="short" />
<cf:property name="ClusterGuid" typeName="guid" />
<cf:method name="LoadBySiteClusterAccountAndDateSpan" body="LOAD ( SiteGuid, ClusterAccountGuid, Datetime DateFrom, Datetime DateTo) WHERE Date &gt;= @DateFrom AND Date &lt;= @DateTo AND ClusterAccountGuid = @ClusterAccountGuid AND SiteGuid=@SiteGuid  ORDER BY Siteguid ASC, Date ASC" />
<cf:method name="LoadBySiteClusterAccountAndDate" body="LOADONE (SiteGuid, ClusterAccountGuid, date) WHERE ClusterAccountGuid = @ClusterAccountGuid AND SiteGuid =@SiteGuid AND Date = @date" />
<cf:method name="LoadByUserAndDateSpan" body="LOAD (ClusterAccountGuid, Datetime DateFrom, Datetime DateTo) WHERE Date &gt;= @DateFrom AND Date &lt;= @DateTo AND ClusterAccountGuid = @ClusterAccountGuid ORDER BY Date ASC" />
<cf:method name="LoadByObjectAndDateSpan" body="LOAD(ObjectGuid, Datetime DateFrom, Datetime DateTo) WHERE Date &gt;= @DateFrom AND Date &lt;= @DateTo AND  ObjectGuid  = @ObjectGuid ORDER BY Date ASC" />
<cf:method name="LoadByObjectAndDate" body="LOADONE (ObjectGuid,Date ) WHERE Date =@Date AND ObjectGuid = @ObjectGuid" />
<cf:method name="LoadByCwSiteCluster" body="LOAD (ClusterGuid) WHERE ClusterGuid = @ClusterGuid" />

When I set the 'CostTotalExclVat' of an existing item, the CodeFluentEntityState remains 'Unchanged' so it won't save the changes. It probably had something to do with 'trackingModes'. But I don't know the correct setting. I don't want any concurrency check or _lastSave etc. What am I doing wrong?


Solution

  • The reason is definitely the trackingMode="none" you set at this property level. If you change only this property, when Save is called, the entity is considered Unchanged.

    Concurrency check is done at entity level, not property level. So if you do not want Concurrency check (ckecking something else saved the entity between your load and your save comparing the Rowversion automatically set when saving) the related setting at Entity level is the property concurrencyMode. The default value is "optimistic" to raise ConcurrencyException when changes have been done between load and save. You can set it to None (as you did) to have no exception and allow any saving on this entity. If you need a very specific management for a given property but not others, while using default Concurrency at entity level, you could use for example :

    And to finish : the "_lastSave" mentioned. If you are refering to the automatic tracking columns "[_trackLastWriteTime/User]" in database. It is also an entity level feature. By default it is written when there are updated in DB. It is not related to a given property. If you do not want to have these information in database for this entity, you can change the entity Level Tracking Modes attribute, which is set by default to Time/User and /CreationState ("[_tracCreationTime/User]" ) to None.