Is displaying 100 rows with 20 fields out of the CSLA scope?

Is displaying 100 rows with 20 fields out of the CSLA scope?

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


Rayk posted on Thursday, August 17, 2006

I am looking at using CSLA for the business logic layer of our application.  However, before the user actually gets to a business object, they need to browse roughly 100 rows of data with about 20 fields.  Then, by clicking on a row, they can access the screen that will represent the business object.

Should I be using a ReadOnlyList object, or something outside of CSLA?  

Basically, I need to know the best way to get such a 'data set' into the WinForm, so I can put it into a grid.  Later, I may want to create a report using DevExpress or some other such tool.   I still need this 'data set' to flow to the WinForm using one of the CSLA methods, either direct SQL, remoting, or web service. 

Thanks,

-Ray

ajj3085 replied on Thursday, August 17, 2006

What you want is not at all outside the scope of Csla.  Just create a root collection object, based off of ReadOnlyList.  The objects in the list will also be readonly, but have a method which can load the editable version of the object.

HTH
Andy

Rayk replied on Thursday, August 17, 2006

Great, thanks for the quick response. 

My original attempt of creating a TripList object as a ReadOnlyListBase using a TripInfo object as a ReadOnlyBase didn't go so well.  I'm sure I've done something incorrect.  I was using the CodeSmith templates, but maybe I better code this first one up by hand until I understand what I'm doing.

Thanks again,

- RayK


skagen00 replied on Thursday, August 17, 2006

It absolutely should work - keep at it. (Make sure the problem isn't with your select from the DB as well, though I'm sure you've ruled that out.)

 

skagen00 replied on Thursday, August 17, 2006

I agree, this should be no problem at all in a WinForms app. Do as Andy suggested.

david.wendelken replied on Thursday, August 17, 2006

I loaded 14,000 records with over 20 properties into a ReadOnlyList yesterday - faster than I could blink.

That was on a Virtual PC where everything it does is usually excruciatingly slow.

If it takes too long to render all those properties on a page, I don't think the Csla code will have anything to do with it.

Rayk replied on Friday, August 18, 2006

Thanks once again for all the support.  My first post on this forum, and I got the confirmations I needed to go forward within an hour, and more confirmations by the next morning.  Just the kind of community support that makes me think using CSLA will be a good decision. 

- RayK

Rayk replied on Friday, August 18, 2006

Thanks to your help, I got this to work. 

Just for info, using the CodeSmith templates to generate the ReadOnlyBase object and ReadOnlyList object doesn't seem to work.  It only gets you part of the way there.  The problem seems to be two things:

The ReadOnlyList object trys to pass the entire SafeDataReader object to the ReadOnlyBase object, which the ReadOnlyBase object doesn't have a method for. 

The second problem is that the ReadOnlyBase object created with CodeSmith templates is primarily for fetching a single ReadOnlyBase object.  It is not designed to be created within the ReadOnlyList. 

So, the procedure I used was:
1.  Modify the ReadOnlyBase object to accept all 20 fields as parameters, just like the ProjectInfo object from the book.   (And created the INTERNAL method for creation).
2.  Modify the ReadOnlyList object to pass in all the fields required by the ReadOnlyBase object, just like the ProjectList object from the book. 

Seems to load 500+ rows without any detectable speed delay. 

-RayK


ChristianPena replied on Friday, August 18, 2006

I noticed the same issue with the templates. I am just starting out, but when I get a hang of using CodeSmith and editing, I will be making that one of my first edits to the templates.

gregwilliams replied on Friday, August 18, 2006

Thanks for the heads up. I was just getting ready to use the Codesmith templates to do the same thing. Guess i will have to modify my approach.

rasupit replied on Friday, August 18, 2006

Just for info, using the CodeSmith templates to generate the ReadOnlyBase object and ReadOnlyList object doesn't seem to work.  It only gets you part of the way there.

RayK,

I don't have any problem generating this type of combo using CodeSmith.  I thinkg you may choose the wrong template here.

What templates do you use to generate these objects.

Ricky

Rayk replied on Monday, August 21, 2006

Ricky, I could very well be using the CodeSmith templates incorrectly.  I have tried several variations though, and I haven't gotten them to work.

Basically, I used the ReadOnlyRoot.cst to create my basic object with my 20 fields.  This also includes the data extraction methods to extract 1 read-only record given the primary key.   Since I need to put this object into a collection somehow, I really don't need the data extraction, but it is nice to have in case I need to display this object 1 at a time. 

Then, I am using the ReadOnlyRootList.cst template.  In this template, I have to specify which object is the 'list' object, so I tell it the one I created in ReadOnlyRoot. 

I could very well be doing something wrong, but I haven't found much documentation on the templates, but I could be missing something. 

Thanks again, RayK


JoeFallon1 replied on Monday, August 21, 2006

FYI,

The original VB templates were a good starting point but I am not sure they were ever 100% finished.

I believe Ricky has been updating the C# templates all along and I assume they are in good shape.

Check out http://www.onelittlevictory.com/  for good samples of each CSLA type and how it should "normally" be structured. Use this to update your templates as needed.

 

Joe

 

JoOfMetL replied on Monday, August 21, 2006

Hello,

I recently started to use the templates of CodeSmith and for the moment I do not find problem.

 If I understood well, you want an example of the type ProjectList and ProjectInfo. 

For my part, I use the template :    

    ProjectList: ReadOnlyRootList.cst   
    ProjetcInfo: ReadOnlyChild.cst

Indeed it will then not be possible to directly charge an "ProjectInfo" object.

rasupit replied on Monday, August 21, 2006

RayK,

To concure with JoOfMetL, you'll need to use ReadOnlyRootList & ReadOnlyChild template.  ReadOnlyRoot template is to be used when you need to retrieve a single object.

There is no document that explain the purpose of each template, however by completing chapter 7 and 8 from the book, these template should be pretty easy to use. 

Joe, welcome back, long time no post ;)

C# templates for Csla 2.0 are a complete rewrite to handle many kinds of data source.  Imo, they are much better and more stable than the 1.x version.  Allan Nielsen has converted these templates to vb version.  If you haven't already try it, please check them out at CslaContrib.

Ricky

JoeFallon1 replied on Tuesday, August 22, 2006

Ricky,

Thanks for the info.

Allan has done some excellent work converting the C# templates to VB.

When I build my 2.0 templates I plan to review the output from Allan's VB templates and modify mine to include things I may have overlooked.

Thanks again for pointing this out.

Copyright (c) Marimer LLC