A couple of people mentioned they are having problems getting adding to work in my example.    I think there are two issues that are getting people.  See the full series


1. You need to hit submit after you add.. Adding only adds to the local collection, to push it to the database, you need to call submit changes.   If you’d like to have Add.. always add it to the database, simply add a call to SubmitChanges(). (line 8).  But notice this does do a network operation..

   1: void addNewWindow_Closed(object sender, EventArgs e)
   2: {
   3:     var win = sender as AddNewWindow;
   4:     var context = dds.DomainContext as SuperEmployeeDomainContext;
   5:     if (win.DialogResult == true)
   6:     {
   7:         context.SuperEmployees.Add(win.NewEmployee);
   8:         context.SubmitChanges();
   9:     }
  10: }


2. You need to set Issues to some number greater than 100.  Otherwise it will add it to the database, but it gets filtered out when the list is refreshed.   Look at this code from the DomainService.. see line 4? 

   1: public IQueryable<SuperEmployee> GetSuperEmployees()
   2: {
   3:     return this.Context.SuperEmployeeSet
   4:                .Where(emp=>emp.Issues>100)
   5:                .OrderBy(emp=>emp.EmployeeID);
   6: }

Really, I guess I should hint that to the user by setting a min value for issues in the add dialog.  You can do that by changing the range attribute in the SuperEmployeesDomainService.metadata.cs file. 

   1: [Range(100, 10000,
   2:     ErrorMessage = "Issues must be between 100 and 1000")]
   3: public Nullable<int> Issues;


Related a common question has been how to write code that get’s called *after* the initial load of data is done.  Mostly RIA Services’ programming model avoids you having to deal with it, but sometimes there is no other way.  So here is a simple example of how to run some code after a load operation is complete.

   1: var context = dds.DomainContext as SuperEmployeeDomainContext;
   2: originFilterBox.ItemsSource = context.Origins;
   3: context.Load(context.GetOriginsQuery(), (lo) => 
   4: { 
   5:     //just to show you how to load..  
   6:     new ErrorWindow("Loaded.."+lo.Entities.Count()).Show(); 
   7: },null);

Hope this helps!  I have updated the demo files