public int Delete(int?id, Csla.SmartDate modifiedDate)
 {
     using (var entities = new AdventureWorks2014Entities())
     {
         entities.Database.Log += WriteLog;
         var model = entities.ProductSubcategories.SingleOrDefault(b => b.ProductSubcategoryID == id && b.ModifiedDate == modifiedDate.Date);
         entities.ProductSubcategories.Remove(model);
         return(entities.SaveChanges());
     }
 }
        public int Read(int?id)
        {
            using (var entities = new AdventureWorks2014Entities())
            {
                entities.Database.Log += WriteLog;
                var model = entities.ProductSubcategories.SingleOrDefault(b => b.ProductSubcategoryID == id);
                this.Id           = model.ProductSubcategoryID;
                this.CategoryId   = model.ProductCategoryID;
                this.Name         = model.Name;
                this.RowGuidId    = model.rowguid;
                this.ModifiedDate = model.ModifiedDate;

                return(1);
            }
        }
 public int Update(int?id, int?categoryId, string name, Guid rowGuidId, Csla.SmartDate modifiedDate)
 {
     using (var entities = new AdventureWorks2014Entities())
     {
         try
         {
             entities.Database.Log += WriteLog;
             var model = entities.ProductSubcategories.SingleOrDefault(b => b.ProductSubcategoryID == id);
             model.ProductCategoryID = categoryId.Value;
             model.Name         = name;
             model.rowguid      = rowGuidId;
             model.ModifiedDate = DateTime.Now;
             return(entities.SaveChanges());
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException ex)
         {
             var temp = ex.EntityValidationErrors.Select(b => b.ValidationErrors.Select(c => c.ErrorMessage)).ToList();
             throw;
         }
     }
 }