DataPortal.BeginFetch

DataPortal.BeginFetch

Old forum URL: forums.lhotka.net/forums/t/11106.aspx


vbbeta posted on Monday, January 30, 2012

Can anyone provide me a real life sample of how a DataPortal.BeginFetch with a data access that talks to a database and then send it back to a winForms grid, (if there is away to get this done)

RockfordLhotka replied on Monday, January 30, 2012

Windows Forms doesn't natively understand async loading of data, so you will probably need some UI code to manage the process. Specifically, you'll need to set the bindingsource control to the new business object inside the callback from the BeginFetch.

For example:

    private void Form1_Load(object sender, EventArgs e)
    {
      TestList.GetTestList((o, a) =>
        {
          if (a.Error != null)
          {
            MessageBox.Show(a.Error.Message);
          }
          else
          {
            this.testListBindingSource.DataSource = a.Object;
          }
        });
    }

The implementation of the factory method and the DataPortal_XYZ method (or factory fetch method) are the same as in any of the samples or in the Using CSLA 4: Data Access book. 

tiago replied on Monday, January 30, 2012

That's why I voted for a WinForms ebook Wink

Copyright (c) Marimer LLC