0 Comments

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.