In one of my projects,I use WCF data services for querying the database,and use GridView, and DataForm for viewing and editing data.When the user double click on a row, I create a filtered DataServiceQuery (e.g. ID=55) and use it to initialize a QueryableDataServiceCollectionView<T> which I then assign to the RadDataForm ItemsSource.I can successfully add ,delete, and edit records by calling SubmitChanges() on the ItemsSource (which is of type QueryableDataServiceCollectionView<T>),
but I am facing other difficulties:
1-I have an entity Sim
which has a 1 to many association property called Installations.
When clicking Cancel while editing or inserting in the DataForm, I get the following error which seems to be caused by the DataForm trying to set a value on the Installations
Setting an instance of DataServiceCollection to an entity property is disallowed if the instance is already being tracked. Error occurred on property 'Installations' for entity type 'TDS.DeviceManagementDataService.Sim'.
2-When I open an existing record for editing,and click the 'insert' button,fill-in the form,and click save,the record is saved but the form goes back and display the record that was being edited earlier.
My last question is: what is the best way of databinding a RadDataForm when working with WCF data service ?
GridView Double Click Code:
sender, MouseButtonEventArgs e)
SimView view =
QueryableDataServiceCollectionView<Sim> dataContext =
Telerik.Windows.Data.QueryableDataServiceCollectionView<Sim>(db, db.Sims.Where(i => i.ID == SimsGridView.GetSelectedItem<Sim>().ID).ToDataServiceQuery<Sim>());
dataContext.PageSize = 100;
view.DataContext = dataContext;
Thanks in advance