Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdapter Question
Message
De
25/04/2005 14:09:13
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01008137
Message ID:
01008177
Vues:
18
Kevin,

>First, in an application, there might be a hundred different calls to the same
>table, each pulling different columns. Would you create a different class for each?
>That could be alot of classes.

Yes, it could be a lot of classes. There are many different ways to approach this question. Some people make different CA subclasses for each specific QUERY they want, including maybe multiple ones for each table that would specify just the fields you need and the where clause (probably parameterized). This might include CAs like caCustomer, caCustsByState, etc.

Others prefer to code CA subclasses more in the style of business objects, with multiple methods added to each that switch around added properties like cSelect, cWhere, cOrder, then dynamically intercept and change the SelectCmd in the BeforeCursorFill method (which persists then for any CursorRefresh calls). This might include methods on a caCustomer subclass like GetListByState, GetByPK, and so forth.

Still others would say to create a different class (like what you suggested based on Session) and put those methods there, and have them instantiate a generic CA and set its properties.

You probably will want to just build a few scenarios and try different approaches to find where you hit the wall and back yourself into a corner. That's what I'm doing right now on a major project that will use CAs, and I'll be speaking about it in a session at DevTeach in June.

Bottom line: There is not one "right" way to use CursorAdapters. :-)

>Second, what about dynamic queries? You never know exactly what data is needed and
>the what the resulting cursor structure will be until the user submits a query.

I have a caQuery subclass for use as a utility class for dynamic queries on whatever table or combination of tables might be needed. For it, you just set a SelectCmd and optionally set the lDetachCursor property (I keep it .t. by default). In the AfterCursorFill() method, I check that property and if true, call THIS.CursorDetach(). This allows me to quickly use the same instance of caQuery to pull multiple cursors one after another into different detached cursors where that might be more efficient.

However, for most of my CA uses, I am building one CA subclass for each table.
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform