Page 1 of 1

System.InvalidOperationException:"Cannot refresh Entity...

Posted: Wed 06 Jan 2010 18:39
by Ramoned
dotConnect version: 5.35.62

Code: Select all

using(DataContext db = new DataContext(Program.ConnectionString))
{
                CAETMSGLOG log = new CAETMSGLOG();
                log.RECEIVEDBYUSER = 0;
                log.FROMID = msg.From.Matricula;
                log.TOID = msg.To.Matricula;
                log.MSGTEXT = msg.Message;
                log.MSGDATE = DateTime.Now.Date;
                db.CAETMSGLOG.InsertOnSubmit(log);
                db.SubmitChanges(); <- error
}

Code: Select all

System.InvalidOperationException was unhandled
  Message="Cannot refresh Entity. Record does not exist."
  Source="Devart.Data.Linq"
  StackTrace:
       at Devart.Data.Linq.Provider.DataProvider.GetAutoSyncValues(MetaType type, IDbCommand dbCommand, IList`1 autoSyncFields, IList`1 autoSyncParameters, IList`1 keyFields, IList`1 keyParameters)
       at Devart.Data.Linq.v.b(MetaType A_0, q A_1, Boolean A_2)
       at Devart.Data.Linq.e.a(h A_0, Object A_1, ModifiedMemberInfo[] A_2, Boolean A_3)
       at Devart.Data.Linq.k.a(e A_0, h A_1, Boolean A_2)
       at Devart.Data.Linq.k.a(DataContext A_0, ConflictMode A_1)
       at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
Table:

Code: Select all

CREATE TABLE CAETMSGLOG
    (MSGID                        NUMBER(11,0) NOT NULL,
    MSGTEXT                       VARCHAR2(800) NOT NULL,
    MSGDATE                       DATE NOT NULL,
    FROMID                        NUMBER(6,0) NOT NULL,
    TOID                          NUMBER(6,0) NOT NULL,
    RECEIVEDBYUSER                NUMBER(1,0) DEFAULT 0,
    MSGHASH                       VARCHAR2(2048) NULL);
    
ALTER TABLE CAETMSGLOG
ADD CONSTRAINT PK_CAETMSGLOG PRIMARY KEY (MSGID);

CREATE SEQUENCE SEQ_CAETMSGLOG;

CREATE TRIGGER TRG_CAETMSGLOG
 BEFORE
  INSERT
 ON CAETMSGLOG
REFERENCING NEW AS NEW OLD AS OLD
 FOR EACH ROW
BEGIN
    SELECT SEQ_CAETMSGLOG.NEXTVAL
    INTO :NEW.MSGID FROM DUAL;
END;
Entity:

Code: Select all

  [Table(Name = @"CAETANO.CAETMSGLOG")]
    public partial class CAETMSGLOG : INotifyPropertyChanging, INotifyPropertyChanged    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private double _MSGID;

        private string _MSGTEXT;

        private System.DateTime _MSGDATE;

        private int _FROMID;

        private int _TOID;

        private int _RECEIVEDBYUSER;

        private string _MSGHASH;
    
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnMSGIDChanging(double value);
        partial void OnMSGIDChanged();
        partial void OnMSGTEXTChanging(string value);
        partial void OnMSGTEXTChanged();
        partial void OnMSGDATEChanging(System.DateTime value);
        partial void OnMSGDATEChanged();
        partial void OnFROMIDChanging(int value);
        partial void OnFROMIDChanged();
        partial void OnTOIDChanging(int value);
        partial void OnTOIDChanged();
        partial void OnRECEIVEDBYUSERChanging(int value);
        partial void OnRECEIVEDBYUSERChanged();
        partial void OnMSGHASHChanging(string value);
        partial void OnMSGHASHChanged();
        #endregion

        public CAETMSGLOG()
        {
            OnCreated();
        }

        [Column(Storage = "_MSGID", AutoSync = AutoSync.OnInsert, CanBeNull = false, DbType = "NUMBER(11) NOT NULL", IsDbGenerated = true, IsPrimaryKey = true)]
        public double MSGID
        {
            get
            {
                return this._MSGID;
            }
            set
            {
                if (this._MSGID != value)
                {
                    this.OnMSGIDChanging(value);
                    this.SendPropertyChanging();
                    this._MSGID = value;
                    this.SendPropertyChanged("MSGID");
                    this.OnMSGIDChanged();
                }
            }
        }

        [Column(Storage = "_MSGTEXT", CanBeNull = false, DbType = "VARCHAR2(800) NOT NULL")]
        public string MSGTEXT
        {
            get
            {
                return this._MSGTEXT;
            }
            set
            {
                if (this._MSGTEXT != value)
                {
                    this.OnMSGTEXTChanging(value);
                    this.SendPropertyChanging();
                    this._MSGTEXT = value;
                    this.SendPropertyChanged("MSGTEXT");
                    this.OnMSGTEXTChanged();
                }
            }
        }

        [Column(Storage = "_MSGDATE", CanBeNull = false, DbType = "DATE NOT NULL")]
        public System.DateTime MSGDATE
        {
            get
            {
                return this._MSGDATE;
            }
            set
            {
                if (this._MSGDATE != value)
                {
                    this.OnMSGDATEChanging(value);
                    this.SendPropertyChanging();
                    this._MSGDATE = value;
                    this.SendPropertyChanged("MSGDATE");
                    this.OnMSGDATEChanged();
                }
            }
        }

        [Column(Storage = "_FROMID", CanBeNull = false, DbType = "NUMBER(6) NOT NULL")]
        public int FROMID
        {
            get
            {
                return this._FROMID;
            }
            set
            {
                if (this._FROMID != value)
                {
                    this.OnFROMIDChanging(value);
                    this.SendPropertyChanging();
                    this._FROMID = value;
                    this.SendPropertyChanged("FROMID");
                    this.OnFROMIDChanged();
                }
            }
        }

        [Column(Storage = "_TOID", CanBeNull = false, DbType = "NUMBER(6) NOT NULL")]
        public int TOID
        {
            get
            {
                return this._TOID;
            }
            set
            {
                if (this._TOID != value)
                {
                    this.OnTOIDChanging(value);
                    this.SendPropertyChanging();
                    this._TOID = value;
                    this.SendPropertyChanged("TOID");
                    this.OnTOIDChanged();
                }
            }
        }

        [Column(Storage = "_RECEIVEDBYUSER", CanBeNull = false, DbType = "NUMBER(1) NOT NULL")]
        public int RECEIVEDBYUSER
        {
            get
            {
                return this._RECEIVEDBYUSER;
            }
            set
            {
                if (this._RECEIVEDBYUSER != value)
                {
                    this.OnRECEIVEDBYUSERChanging(value);
                    this.SendPropertyChanging();
                    this._RECEIVEDBYUSER = value;
                    this.SendPropertyChanged("RECEIVEDBYUSER");
                    this.OnRECEIVEDBYUSERChanged();
                }
            }
        }

        [Column(Storage = "_MSGHASH", DbType = "VARCHAR2(2048)")]
        public string MSGHASH
        {
            get
            {
                return this._MSGHASH;
            }
            set
            {
                if (this._MSGHASH != value)
                {
                    this.OnMSGHASHChanging(value);
                    this.SendPropertyChanging();
                    this._MSGHASH = value;
                    this.SendPropertyChanged("MSGHASH");
                    this.OnMSGHASHChanged();
                }
            }
        }
   
        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if (this.PropertyChanging != null)
                this.PropertyChanging(this, emptyChangingEventArgs);
        }

        protected virtual void SendPropertyChanging(String propertyName) 
        {
            if (this.PropertyChanging != null)
                this.PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
             if (this.PropertyChanged != null)
                 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

Posted: Tue 12 Jan 2010 09:43
by AndreyR
I have tried to reproduce the error using the latest 5.35.62 build of dotConnect for Oracle and everything was OK.
Could you please upgrade to the recent version?
Sorry for the delay.

Posted: Tue 12 Jan 2010 13:04
by Ramoned
I re-downloaded the latest 5.35.62 build (which i was already using) and the problem still persist, the problem seems global, no insert in any of the tables with DbGenerated and AutoSync seems to work on the 5.35.62 build, the only way i found to solve the problem was to rollback to version 5.35.54.

Posted: Wed 13 Jan 2010 13:38
by AndreyR
We will investigate the situation.
However, I have just tried the latest build to insert with AutoSync="OnInsert" and succeeded.
Could you please make a simple test project illustrating the problem and send it to me?

Same here

Posted: Fri 22 Jan 2010 15:49
by motuzko
Same here. Had to downgrade to 5.35.57 to make it working.

Posted: Tue 26 Jan 2010 17:04
by AndreyR
Could you please describe the database side of the autoincrement column?
Also please provide a sample code illustrating the submitting of changes.

Posted: Sat 22 Jan 2011 17:00
by emrahsaglik
I have the same problem I have updated the dotconnect to the last version and it started to give this error. I am not able to insert anything in to the table.

Posted: Tue 25 Jan 2011 17:06
by StanislavK
As I can understand, you are using the 5.25.39 version of dotConnect for Oracle. Am I correct? In this case, you probably need to update to a newer version. You can check the latest build you are licensed to in Registered Users' Area:
http://secure.devart.com/

If 5.25.39 is the latest accessible build, you can renew your subscription to get the latest 6.0.86 version; you can do it with the 'Subscription Renewals' section at
http://www.devart.com/dotconnect/oracle/download.html
For information about the fixes and improvements available in the 6.0.86 build, please refer to
http://www.devart.com/dotconnect/oracle ... story.html