Creating A Stereotype Of The ReadOnlyListBase & ReadOnlyBase Objects

Creating A Stereotype Of The ReadOnlyListBase & ReadOnlyBase Objects

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


NickTaylor posted on Tuesday, November 24, 2009

I wonder if someone can offer some advice on this please...

I want to manage a list of objects within a windows form and subsequently use this for displaying data in a grid. The ReadOnlyListBase and ReadOnlyBase objects are ideal other than the fact that I would like to update the list on the fly from within the form. No data however would be written back to the DB via this list as I would use my full business objects for this.

How could I create a stereotype of ROLB and ROB but make them writeable from within the UI ?

Many thanks,

Nick

RockfordLhotka replied on Tuesday, November 24, 2009

Why wouldn't you use BusinessBase and BusinessListBase? They are designed to support read-write properties and the ability to add/remove items from a list.

The read-only base classes have no business rules support, limited databinding support and limited authorization support, because they are for read-only data.

To create an editable stereotype you'll end up replicating nearly all of BusinessBase and BusinessListBase except probably for the Save() methods.

NickTaylor replied on Wednesday, November 25, 2009

Hi Rocky,

I guess I wanted to double check that implementing the BB and BLB classes but perhaps not implementing all the methods that the template provides is an acceptable practice. I guess I shouldn't treat the template as a straight jacket, but rather as a starting point which can be customised if required.

In this instance the BB info object only has its Fetch method populated. As there is no requirement to write data back to the DB, no Update / Insert methods are implemented.

Many thanks for your input...

Best regards,

Nick

RockfordLhotka replied on Wednesday, November 25, 2009

That’s pretty common actually.

 

For example, it is quite common to use a BB object as a criteria object when the user gets to input the criteria. In that case there’s also no save, or fetch – just create. But there are business rules, because the input is validated and then used as criteria for fetching some other object.

 

tiago replied on Tuesday, November 24, 2009

Hi Nick,

I guess you are having trouble implementing the technique explained in the blog entry

"Rockford Lhotka - I Am Working On My Using CSLA NET 30 Ebook And Wrote Some Content That I Dont Think Im Going To Use In The Book"

I enclose and example. The *-Designer.cs files were generated by a very customized version of CslaGen that even supports the technique above. It was tested on Csla 2.0 and 3.7.1.

 

tiago replied on Tuesday, November 24, 2009

Forgot to say this is part of my test bed project and it is used to load a collection of more than 22.000 info objects and does it in around 2 seconds. ReadOnly objects are very fast to load namely because they don't have validation rules. I admit I didn't test similar BusinesBase objects with the same properties and rule checking off... Maybe it's as fast as RO...

NickTaylor replied on Wednesday, November 25, 2009

Hi Tiago,

I will certainly incorporate the methods proposed by Rocky that you described above, however in my scenario I required a little further flexibility.

My customer maintenance form initially contains no data. I then have the usual options to add a new customer, edit a customer etc. etc., and I also provide a search button on the toolbar which opens a search form which then permits the user to select any number of customers, or indeed all customers. I start by displaying a list of all customers which is a simple ( now writable ) list based on BusinessListBase. So thanks to CustomerList.GetAllCustomers() I now see all customers displayed in the search form grid. No problems here.

When the user has selected either all or an assortment of customers, I then create a new list to contain my selected customers, i.e. CustomerList.CreateEmpyList(), and then iterate through the datagrid picking out all the selected rows ( easy to do as I am using an Infragistics ultraGrid, and it has a ListObject property for each grid row ). I then merely add the appropriate customer info objects to the new SelectedCustomerList object.

I then return this to the maintenance form, and use it to drive the forms navigation. Obviously for each navigational movement, I invoke the full BO which then writes any changes back to the DB. Of course adding or deleting customers is easy to maintain in the navigation as I can easily add and remove info objects from the now writable collection.

I'm sure this will work fine, however I have spent most of the day trying to work out how to find a reference to the parent form onto which a bespoke component object has been placed. There is no .Parent property which is understandable, but very annoying!

Any help here would also be welcome!! ;o)

Thanks again,

Nick   

Copyright (c) Marimer LLC