Page 1 of 1

Question on RowVersion TImestamp

Posted: Sat 14 Apr 2018 09:52
by NSY738
HI

I facing a problem it is related to Timestamp.

If i using following code

Code: Select all


using (ApplicationDbContext db = new ApplicationDbContext())
{
	db.Configuration.LazyLoadingEnabled = false;
	db.Configuration.AutoDetectChangesEnabled = false;

	int Oid = dbObj.Id;
	var dbObjUpd = db.OMTrans.Where(u => u.Id == Oid).FirstOrDefault();

	dbObjUpd.Oid = int.Parse(returnedString);
	dbObjUpd.Mupd_DateTime = DateTime.Now;
	db.Entry(dbObjUpd).State = System.Data.Entity.EntityState.Modified;
	db.SaveChanges();
}
then i will get an error likes this.
"The 'RowVersion' property on 'OMTran' could not be set to a 'System.DateTime' value. You must set this property to a non-null value of type 'System.Byte[]'. "


but if i using below code then no problem.

Code: Select all

using (ApplicationDbContext db = new ApplicationDbContext())
{
	db.Configuration.LazyLoadingEnabled = false;
	db.Configuration.AutoDetectChangesEnabled = false;

	List<int> ListObjInt = new List<int>();
	ListObjInt.Add(dbObj.Id);
	var dbObjUpd = db.OMTrans.Where(u => ListObjInt.Contains(u.Id)).FirstOrDefault();

	dbObjUpd.Oid = int.Parse(returnedString);
	dbObjUpd.Mupd_DateTime = DateTime.Now;
	db.Entry(dbObjUpd).State = System.Data.Entity.EntityState.Modified;
	db.SaveChanges();
} 
my omtran class

Code: Select all

 [Table("OMTran")]
    public partial class OMTran 
    {
        public OMTran()
        { 

        }

        [Key] 
        [Column("Id", TypeName = "int")]
        public int Id { get; set; }

        [Display(Name = "Oid")]
        [Column("Oid", TypeName = "int")]
        public int? Oid { get; set; }

        [Required]
        [Column("CompanyId", TypeName = "int")] 
        public int CompanyId { get; set; }

        [Required]
        [Column("StoreId", TypeName = "int")] 
        public int StoreId { get; set; }

        [Required]
        [Column("OMDocId", TypeName = "int")] 
        public int OMDocId { get; set; }
        [ForeignKey("OMDocId")]
        public virtual OMDoc OMDoc { get; set; } 
 

        [Column("Lupd_DateTime", TypeName = "datetime")]
        public DateTime Lupd_DateTime { get; set; }

        [Column("Lupd_UserId", TypeName = "varchar")]
        [StringLength(255)]
        public string Lupd_UserId { get; set; }

        [Column("Lupd_Prog", TypeName = "varchar")]
        [StringLength(50)]
        public string Lupd_Prog { get; set; } 

        [Timestamp]
        public byte[] RowVersion { get; set; }
         
        public ICollection<OMLot> OMLots { get; set; }

    }
is my class problem? or it is standard?

and how to use isTimestamp() method?

Re: Question on RowVersion TImestamp

Posted: Wed 18 Apr 2018 15:00
by Shalex
Thank you for your report. We will investigate the issue and notify you about the result.

Re: Question on RowVersion TImestamp

Posted: Fri 10 Aug 2018 13:44
by Shalex
We cannot reproduce the issue.

Please upgrade your dotConnect for MySQL to v8.12.1202 and try the test project: https://www.devart.com/pub/forum_37039.zip. Modify the project for reproducing and upload it to some file exchange server.