Silverlight 4: Fields disapear in data grid after saving en - silverlight

When saving a new entity something strange happens...
I have a data grid with a list of 'Depots' populated using a domain data source.
When the user wants to add a new 'Depot' this is what happens:
Depot newDepot = new Depot();
newDepot.Name = "My New Depot";
EditDepot popup = new EditDepot(newDepot); // create the popup and pass the newly created Depot
domainDataSource.DataView.Add(newDepot); // add a new Depot to the datagrid
// handle the popup events
popup.CancelClick += (cancelSender, cancelArgs) =>
{
if (GridDataSource.DataView.Contains(newDepot))
domainDataSource.DataView.Remove(newDepot);
domainDataSource.DomainContext.RejectChanges();
};
popup.Show();
The popup constructor then passes the entity to a viewmodel. The viewmodel constructor then creates a new instance of 'ContactInfo', another entity which is linked to 'Depot' (Depot.ContactInfo). After filling in a few properties, the 'Depot' is assigned to a property in the viewmodel and a dataform is used to edit the data. Once the user is happy with the content they will press save. The Depot is added to the context (Context.Depots.Add....) and then the changes are submitted. (It's also worth noting I have tried added the ContactInfo item to the context too, with no joy). The data is saved to the database (via WCF) and everything appears to have worked correctly. The proplem is the datagrid is not displaying the ContactInfo fields, where as it did before the save. As the user edits the data, you can see the datagrid populated behind the popup. If the user refreshes, the data returns. This problem does not happen when the entity is editied.
Now, to throw another spanner in the works... This doesn't happen on all our machines...
We have a build machine and the output does have this problem, however one machine in the building builds a version which does not have this problem! After some investigation, we have found that it appears to be the version of WCF RIA Services. On my machine, I had V1.0 SP1. I Tried V1.0 SP2 and still had the same problem. Now on the machine that works, WCF RIA Services SP1 Beta was installed. After he unistalled this, and installed SP2, the problem occured on his machine.
So, we are relutant to use a beta version in our final release, but unless we can fix this issue we wont have a choice. Does anyone have any ideas? Has anyone seen this issue before?
I have also tried different version of the WCF toolkit with no joy
EDIT: I've created a simple project to show you whats happening
The project retrieves a load of entities and tries to add one. You'll notice the the 'InnerThing' properties dissapear.
Link to project

the issue was that the key property was being set in the insert method in the service.
it looks like this change was not reflected in the client. Changing other properties in the service after submit other than the key did work however.

Related

Any way to automatic update controller and view code once model got updated - Already developed MVC application?

I have one ASP.Net MVC data base first application. Due to some enhancement work came in I have to do modification to my DB tables and Add couple of new table as well.
I saw few tutorial and you tube videos. I found, they are deleting the existing model and controller -> changing the DB schema [adding SP etc...] -> then again adding new model and controller etc. However, I think, this is not the correct approach as my application is bit big[already on production], I can not delete everything and adding again back.
How can I do it? Is that MVC does not provide something so that I can update it from Visual Studio or refresh it so that my changes will affect? Any link would help. Hope my explanation is understood-able.
Along with I also wanted to know, is there any thing else I need to take care for these kind of enhancement?
Any disadvantage of using ASP.NET MVC?
Thanks.
Double click on .edmx file(added in models folder) to open it.Then right click on it and select update model from database and then press ctrl+s to save it.

SIlverlight and SharePoint

I'm currently trying to get data Asynchronously in silverlight to enable me to populate some auto complete boxes and some other display controls.
My silverlight app is based at the root of the site.
With the client object model it's easy to get the title of every web and subweb and sub webs (recusive) however in silverlight i'm not to sure how i go about this.
I have the webs(subWeb1 collection) of the root web and i believe( broken this recently :() i can get the webs(Sub Web 2 collection) but i can't seem to gain access to a list in subWeb 2 that i need access to! I keep getting
The collection has not been initialised. It has not been requested or the request has not been executed. It may need to be explicitly requested
Could anyone shed any light on how you would do this?
Many thanks
There is a Silverlight Client Object Model for just this thing. Here is a post that explains exactly what you are trying to do.

WPF client for class library : how to notify error to UI?

I'm new to WPF and I'm working on a project that will have the following components : a WCF server class library, a WCF client class library, a WPF client UI and a WPF server UI.
I have a method in WCF client that add a user to a collection in the client and then register this user in the server. The method checks that user doesn't already exist locally then register in on the server that throws a FaultException if the user already exist on it.
How can I notify the client that operation doesn't succeed and that he must choose an other name? Throwing an exception? Adding code in ViewModel to check if user exists before calling add method?
Thank you.
IMHO, the best option is to check from the ViewModel on the server if the user already exists, if so, show a message on the UI.
Exceptions must be used for unexpected situations, and this is not the case.
A couple of ways. Take a moment to learn ValidationRules. This should help with that.
How to disable a Button on TextBox ValidationErrors in WPF
Howevever, you could do the same thing without a ValidationRule. Just have some error text that has Visibility bound to a bool in the ViewModel. Of course the error text would only be Visibile if user already exists.
Once you have looked at those two options, you should know which on is best for your project.

PageFunction not being disposed of causes crash

I have a WPF "wizard" where I am using PageFunction objects to display the various pages in the wizard. Several of these pages use references to objects in other assemblies within the application so the user can select "packages" they want to include in a generated ouput. In the page function, I have the keep alive flag set to true so that when the user presses cancel or finish in the wizard I can capture the wizard results and the corresponding data the user selected.
The problem is that the wizard pages never go away even after the scope in which they were created has been exited, Thus, when I try to remove one of the referenced objects that the wizard was databound to from a collection, it causes the wizard page to throw an exception. I cannot seem to find a way to correct this issue without setting the KeepAlive flag to false, but this breaks the ability to capture the user data from the wizard.
Any ideas?
Thanks!
I have something very similar (if not the same). A wizard created with a navigation window and a set of pagefunction pages to collect data. Some of the pagefunction pages are even pulled from assemblies in the application folder but I have never had this problem. Can you be more specific on the problem? How do you try to remove the referenced objects? Can you post some code so I can look at it?

Multiple calls to data service from SL3?

I have an SL3 that makes asynchronous calls to a data service. Basically, there is a treeview that is bound to a collection of objects. The idea is that as a user selects a specific treeviewitem, a call is made to the data service, with a parameter specific to the selected treeviewitem being passed to the corresponding web method in the data service. The data service returns data back to the SL3 client, and the client presents the data to the user.
This works well. The problem is that when users start to navigate through the treeview using the arrow keys on their keyboard, they could press the down arrow key, for example, 10 times, and 10 calls will be made to the data service, and then each of the 10 items will be displayed to the user momentarily, until finishing with the data for the most recently selected treeview item.
So - onto the question. How can I put in some form of delay, to allow someone to navigate quickly through a treeview, then, once then stop at a certain treeviewitem, a call is made to the data service?
Thanks for any suggestions.
Chris
use Rx for silverlight
As suggested by funwithcoding, you could try using the Reactive Extensions for .Net (Rx), I've not used it myself but from what I hear it would do what you're after.
However if you don't feel like you want to / have time to learn Rx etc. maybe look at using a DispatcherTimer to create a slight delay in you Treeview selected event, before you call the service to retrieve the data.

Resources