Good evening,
I am looking for someone to help me with my understanding of how to incorporate the Silverlight DataForm with my ViewModel that using WCF Ria Services. What I am trying to accomplish is using the DataForm manage my collection of entity and utilize its built in navigation, Add, Edit and Delete functionality. Howerver, I am having trouble tying it all together with my ViewModel and Ria Services.
From my understanding, the DataForm needs to be bound to an ObservableCollection<T>
. However when I query from the WCF Ria Service context. ie.
_context.Load(_context.GetAllCustomersQuery(), loadCustomersQueryCallback, true);
I will receive back an IQueryable in the callback method, which i would have to cast as an ObservableCollection<T>
like so?
Customers = new ObservableCollection<Customer>(_context.Customers);
Customers is a property in my ViewModel like so...
public ObservableCollection<Customer> Customers
{
get { return _customers; }
set
{
if (_customers != value)
{
_customers = value;
OnPropertyChanged("Customers");
}
}
}
The DataForm is bound to the Customers Property of the ViewModel and I am able to see the data from my datasource, I can navigate between entities, I can edit an existing entity and persist the changes back to the database however I cannot add or delete entites.
Is what I'm doing with the Customers property correct? have I "disconnected" from the context by casting into a new ObservableCollection and therefore have not actually added or removed the entities from the context?
Any help is greatly appreciated.
Regards,