Refreshing/Refilling a business object


Author
Message
Andria Jensen
Andria Jensen
StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)
Group: Forum Members
Posts: 336, Visits: 497
What's the best way to refresh the data in a business object?  I know you can just call the fill method over again, but I have a situation where this is not going to work.  I am in edit mode on my form, but I have a few un-editable values on the form which may change.  If the values update I want it to reflect on the form.  If I call the fill method, it will take it out of edit mode and back to idle.  Is there a good way to do this?  I thought about having one business object linked to the values I want to be able to refresh, and one that just links off to the editable values that won't refresh. When I need to refresh and they are in edit mode, I only refresh the one business object.  When in idle, it would refresh both.  Is this the right way of thinking about it??
Peter Denton
Peter Denton
StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

To find out if you need to refresh you could use the ReceiveQueryNotifications method on the BO. Here's a snippet from the Documentation:

ReceiveQueryNotifications

The ReceiveQueryNotifications property determines whether a System.Data.SqlClient.SqlDependency will set to listen for Query Notifications that are registered on commands executed through FillDataTable(). When notifications are received, the ServerDataChanged method is raised allowing you to repopulate the business object due to changes within the server's data.

Note: To use Query Notifications, you must adhere to the following requirements:
  • SQL Server 2005 only
  • Properly formatted queries - Queries must follow the rules for a proper Indexed View query. See the Microsoft Developer's Guide for more information.
  • Enable the broker service (ALTER DATABASE [database] SET ENABLE_BROKER) on the database.

 

Once you've determined that you need to refresh perhaps you could

1. If necessary save the current changes

if MyBO.IsDirty then MyBO.Save

2. Determine which row in the table you're in

Dim MyRow as Integer = MyBO.CurrentRowIndex

3. Refill the BO by whatever means

4. Get back to where you were

MyBO.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.Absolute, MyRow)

5. Get back into edit mode

MyBO.Edit()

Hope this helps. I haven't used the ReceiveQueryNotifications property, but I read about it some time ago and thought it might be useful.

Peter

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Andria,

Peter has a good idea and this is the purpose of a query notification.  But the one thing that would happen is that when you receive the query notification you will still have to call a Fill method of some kind.  What I would do, as you had mentioned, is create a separate instance of a BO and call the Fill on that BO.  Then if records are returned, you can filter out any duplicate records or records that have been modified on your edit BO.  Once you have the filter on the second BO the way you like it, call the CopyDataFrom method on the primary BO and pass it eh secondary BO and use the AppendFromDefaultView option.  This would probably be the best solution for what you are trying to accomplish.

Andria Jensen
Andria Jensen
StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Well, sorry to rain on the parade but I can't use SQL 2005 specific methods.  Our application has to stay database neutral so that we can support Oracle and SQL.  Thanks for the answers though. 
Andria Jensen
Andria Jensen
StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)StrataFrame User (444 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I'm going to attempt to try what Trent has suggested.  I think I follow, but I may get stuck at some point so expect to see me back here asking another question BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Sounds good, Andria. Smile Let me know if you need more details.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search