Example #1
0
        public WasteFactor Edit(WasteFactor factor)
        {
            factor.ModifiedOn = DateTime.Now;
            WasteFactor dbfactor = Single(factor.ID);

            // get the database columns which need to be updated
            var databaseMembers =
                db.Mapping.MappingSource.GetModel(typeof(BizzyQuoteDataContext)).GetMetaType(typeof(WasteFactor)).DataMembers
                    .Where(d => d.IsAssociation == false && d.IsDbGenerated == false && d.IsPersistent == true);

            // reflect to get instances of the entity preoprties
            var editProperties =
                from p in dbfactor.GetType().GetProperties()
                join m in databaseMembers on p.Name equals m.Name
                select p;

            // copy the values
            PropertyInfo[] editProps = editProperties.ToArray();
            foreach (PropertyInfo propertyInfo in editProps)
            {
                propertyInfo.SetValue(dbfactor, propertyInfo.GetValue(factor, null), null);
            }

            db.SubmitChanges();
            return dbfactor;
        }
Example #2
0
        public WasteFactor Create(WasteFactor factor)
        {
            factor.CreatedOn = DateTime.Now;
            factor.ModifiedOn = DateTime.Now;

            db.WasteFactors.InsertOnSubmit(factor);
            db.SubmitChanges();
            return factor;
        }
Example #3
0
 partial void DeleteWasteFactor(WasteFactor instance);
Example #4
0
 partial void UpdateWasteFactor(WasteFactor instance);
Example #5
0
 partial void InsertWasteFactor(WasteFactor instance);
Example #6
0
		private void detach_WasteFactors(WasteFactor entity)
		{
			this.SendPropertyChanging();
			entity.ProductLine = null;
		}
Example #7
0
		private void attach_WasteFactors(WasteFactor entity)
		{
			this.SendPropertyChanging();
			entity.Product = this;
		}
Example #8
0
		private void detach_WasteFactors(WasteFactor entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}