System.InvalidOperationException:"Cannot refresh Entity...

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Ramoned
Posts: 2
Joined: Wed 06 Jan 2010 17:46

System.InvalidOperationException:"Cannot refresh Entity...

Post by Ramoned » Wed 06 Jan 2010 18:39

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));
        }
    }

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 12 Jan 2010 09:43

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.

Ramoned
Posts: 2
Joined: Wed 06 Jan 2010 17:46

Post by Ramoned » Tue 12 Jan 2010 13:04

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 13 Jan 2010 13:38

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?

motuzko
Posts: 54
Joined: Tue 08 Sep 2009 18:02
Contact:

Same here

Post by motuzko » Fri 22 Jan 2010 15:49

Same here. Had to downgrade to 5.35.57 to make it working.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 26 Jan 2010 17:04

Could you please describe the database side of the autoincrement column?
Also please provide a sample code illustrating the submitting of changes.

emrahsaglik
Posts: 2
Joined: Sat 22 Jan 2011 16:49

Post by emrahsaglik » Sat 22 Jan 2011 17:00

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.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 25 Jan 2011 17:06

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

Post Reply