Suppose I have an EntityCollection say it's Context.Phones. At client side, it is loaded by WCF Ria Service, say there are 5 phones loaded from DB by Wcf ria service+EF.
then at client side, I issued Context.Phones.Detach(phone). then recall wcf ria service reload the data. it is fine, 5 phones records will be back in Context.Phones.
but if I do Context.Phones.Remove(phone) at client side, then reload the data with wcf ria service, Context.Phones always only has 4 phones, not 5 phones unless I rerun the whole SL app. How to resolve this problem? what's the difference between Remove and Detach?
To refresh your entities, you can use LoadBehavior.RefreshCurrent when reloading your entities:
mycontext.Load(mycontext.GetPhonesQuery,
LoadBehavior.RefreshCurrent,
AddressOf MyCallback,
Nothing)
Another way to go: If aren't tied to your current context, you can always create a new context and use that.
Detach does not mark your entity (and its object graph) for deletion. It is used to move your entity from one context to another.
Remove will mark your entity for deletion.