Multiple Tables Revisited


Author
Message
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

While I really like what I’ve learned about the framework to date I’m still having some problems understanding the best way to apply it. I think most of my issues surround object mapper and its one object to one table relationship.   For example I’m wondering what is the best way to address the following situation using StrataFrame. I have three tables, User, Role, and Role Assignment. RoleAssignment maintains a many to many relationship between User and Role and in addition to it’s primary key only contains the foreign keys to the other tables.

 

I want to display user and role assignments in a list view.  In another framework I would have created a read-only object that would contain user names, roles, along with the associated keys and any additional information I wished to get from the User and Role tables, and populated it using a stored procedure. However since object mapper only maps one object to one table this presents a problem. I suppose one solution would be to create a complex business object. I could also drop all the objects on the form and maintain the relationship between them on the form. My goal is to insulate the UI developer from the underlying data structure as much as possible. Any suggestions? While this example is for a read only object, I have the same questions when dealing with multiple editable objects on a form. 

 

Finally does MicroFour plan on offering any formal training classes or consulting services in the future?

 

-Larry

Replies
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K
I’m still wrestling with the situation where I require fields from other tables for display purposes and the fact that the business object must match the single table structure in the DB to save it. It would be nice if there were a way to mark individual fields as savable or not, or if the object were smart enough to only try and save/update fields defined by object mapper, allowing you to have a single instance of an object that could provided the required behaviors without being so closely tied to the underlying data structure. However I imagine doing so would require some significant changes to the framework. Therefore my question what is the recommended approach to handle this situation? Should I create two instances of the object, one that includes fields from other tables for display purposes and one without for updating? Or should I simply add the other objects/tables to my form and pull the added fields from them on the form? Most of what I’m doing is manipulating a List View to allow the user to work with the information is a user friendly way before saving the results (mostly just foreign keys) to the DB. Some other solutions come to mind, but I’d like your input on what is the most efficient way to do this within SF.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, generally we iterate through the fields within the internal data table to save, however, it would not be hard to iterate through the AllFieldsList collection rather than the columns on the DataTable... would probably be faster as well. I'll take a look and see what sort of enhancement this would require.



You also might have your "savable" business object standing by. You could clear it and then use the MergeDataFrom method to copy only in only the columns that should be saved on the business object.



private void SaveRecords()

{

//-- Clear the business object being used to save

SavingBO.Clear();



//-- Copy in the data to be saved from the list view bo

SavingBO.MergeDataFrom(ListViewBO, MergeDataTableOptions.MergeFromCompleteTable_ReplaceExistingDuplicates);



//-- Save the business object as it will only have the columns that can be saved

SavingBO.Save();

}



Hope this helps Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search