Get only the changed data from the database with Linq to SQL and .NET RIA Services in Silverlight 3

If you cache data in you’re Silverlight 3 application and want to sync (get the latest data from the database) the entities, you can use the Load function with the LoadBehavior.RefreshCurrent option. This will get the latest data from the database, but only the changed entities.

private EntitySet<TTUser> _userData;
        public EntitySet<TTUser> UserData
        {
            get
            {
                return _userData;
            }
            set
            {
                _userData = value;
            }
        }

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (WebContext.Current.User.IsAuthenticated)
            {
                TTSDomainContext context = new TTSDomainContext();
                this.UserData = context.TTUsers;
                tasksDataGrid.ItemsSource = this.UserData;
                context.Load(context.GetUsersQuery(),LoadBehavior.RefreshCurrent,true);
            }
        }

 

You can use the Submitchanges() function to update the database.