how to create moq for property in entity framework

13 views
Skip to first unread message

solai kannan

unread,
Oct 8, 2015, 12:19:19 PM10/8/15
to Moq Discussions
hi can anyone help how to write moq for entity for the method given below.
especially for properties like "db.Entry(driver).Property(x => x.EffectiveDate).IsModified = true;"

 public bool UpdateEffectiveDate(int driverId, DateTime effectiveDate, string UserId)
        {
           db myentity=new myentity();
            Driver driver = db.Drivers.Find(driverId);
            driver.EffectiveDate = effectiveDate;
            driver.LastModifiedBy = UserId;
            driver.LastModifiedDate = DateTime.Now;
            db.Drivers.Attach(driver);
            db.Entry(driver).Property(x => x.EffectiveDate).IsModified = true;
            db.Entry(driver).Property(x => x.LastModifiedBy).IsModified = true;
            db.Entry(driver).Property(x => x.LastModifiedDate).IsModified = true;
            return (db.SaveChanges() > 0);

        }



thanks in advance
Reply all
Reply to author
Forward
0 new messages