Get number of records from a table?

Get number of records from a table?

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


reagan123 posted on Friday, January 11, 2008

Hopefully this has a simple answer.  Suppose I have a table called "Personnel" and I want to find out how many records are in that table from my UI using CSLA... What is the proper way to do this?  Would this be a case when I need to use the commandObject?

Any help greatly appreciated!

 

KKoteles replied on Friday, January 11, 2008

reagan123,

That would be a perfect case for using the CommandObject.  Just follow Rocky's example of the ExistsCommand within the Project class of the ProjectTracker application.  In your case it is even simpiler because you do not need to pass in a parameter (unless for some reason you would need to).  I assume you will have an object named "Personnel".  Just add a static RecordCount method (or some other similar type name) to your Personnel object.

Ken

reagan123 replied on Friday, January 11, 2008

Works great! Thanks.

Copyright (c) Marimer LLC