SL5+WCF Ria +ef
Beginner level
After SQL Server manually modified the database data, and then to the foreground to refresh the data, found that the data has not changed, the service side return and the foreground inconsistency
Service-side code
Public iqueryable<customer> Getcustomerbycustomerid (string customerId)
{
return this. ObjectContext.Customer.Where (E = E.customid = = customerId);
}
Client Update button Code
private void Button_Click (object sender, RoutedEventArgs e)
{
Customercontext.load<customer> (Customercontext.getcoustomerbycustomeridquery ("000001")). Completed + = (s, x) = =
{
Customer = (Customer) ((loadoperation<customer>) s). Entities.firstordefault ();
MessageBox.Show (Customer. Customname + customer. Address);
};
}
For example, the CustomerName and customeraddress of number 000001 have been modified
View return data in the background
Data obtained at the front desk
The reason cannot be clearly expressed, it should be related to the persistence context of EF
A temporary solution
Call the Entitycontainer.clear () method of the context Customercontext before invoking the background service
Hope that in-depth study of EF can improve, but also hope that the specific reasons for you
Use EF to generate the data model and then modify the data directly in the database, and the data is unchanged after the foreground refresh