static void Main(string[] args) { var ctx = new ProductManagerDataContext(); var data = ctx.Products.AsQueryable().Take(5).ToList(); data.First().ListPrice++; ctx.SaveChanges(); //var category = new ProductCategory //{ // Name = "Test Category 1", //}; //var product = new Product //{ // ProductID=1111, // Name = "Test Product 1", // ProductNumber = "Test Product 1", // SellStartDate = DateTime.Now.Date, //}; //product.ProductCategory = category; //ctx.Add(product); //ctx.SaveChanges(); }
public bool Save() { bool saved = false; if (!CanSave()) { throw new InvalidOperationException("You must not call Save when CanSave returns false."); } try { shellViewModel.SetWaitCursor(); context.SaveChanges(); shellViewModel.ReleaseWaitCursor(); saved = true; } catch (NTier.Client.Domain.ServerValidationException ex) { messageService.ShowError(string.Format(CultureInfo.CurrentCulture, Resources.SaveErrorInvalidEntities, ex.Message)); } catch (NTier.Client.Domain.UpdateException ex) { messageService.ShowError(string.Format(CultureInfo.CurrentCulture, Resources.SaveErrorInvalidFields, ex.InnerException.Message)); } return(saved); }