|
FoxDataObjects |
Object-Relational Mapping Tool for Visual FoxPro® |
|
|
fdoCollection Class |
||
|---|---|---|
The fdoCollection is an easy to use collection class specially designed to implement one-to-many and many-to-many relationships, as of collection of simple values in your business classes. Although Visual FoxPro 8 (and up) features a basic Collection class, the fdoCollection class provides an extra number of functions and features that simplifies object relationships management, implement collection-level events, provides a way to easily access modified/added and even removed item, optimizes memory usage and accelerate referenced instances loading with a powerful collection-level lazy loading mechanism.
As any other collection, the fdoCollection class exposes
the Count and Item properties, along with Add, Remove
and Clear methods. It can be
used to store objects
references or simple values. With object references, it provides specialized
methods that allows to know whether a specific reference has been loaded (for
lazy loaded references), the original count value and referenced objects
identifiers when the holder object was retrieved or last saved into the
database, separated list of added, modified and removed
items, and much more. It also provides a complete set of events or procedure-hooks
that are automatically called when the collection initializes, destroys, clears; or
items are added or removed.
The following tables shows the properties and methods exposed by the
fdoCollection class. This class can be sub-classed in order to implement
specific
collection level functionality appropriate for your business classes.
| Properties | |||||||||||||||||||
|
|||||||||||||||||||
| Methods | ||||||||||||||||
|
||||||||||||||||
| Events | |||||||||||||||||||
|
|||||||||||||||||||
|
Example |
|
|
DEFINE CLASS Invoice AS CONTAINER InvNumber=0 InvDate=Date() Customer=.NULL. Total=0.0000 ADD OBJECT lines AS fdoCollection WITH ReferencedClass="InvoiceLine"
PROCEDURE OnSave (oSession) ? "Actual invoice lines:",This.Lines.Count
? "Modified Lines:",This.Lines.ModifiedCount ? "-----------------------------------------" FOR EACH oItem IN THIS.Lines.ModifiedItem ? oItem.Product.Code,oItem.Product.Description, oItem.Quantity ENDFOR
? "Added Lines:",This.Lines.AddedCount ? "----------------------------------" FOR EACH oItem IN THIS.Lines.AddedItem ? oItem.Product.Code,oItem.Product.Description, oItem.Quantity ENDFOR
? "Removed Lines:",This.Lines.RemovedCount ? "----------------------------------" FOR EACH oItem IN THIS.Lines.RemovedItem ? oItem.Product.Code,oItem.Product.Description, oItem.Quantity ENDFOR
? "Original invoice lines:",This.Lines.OldCount FOR EACH oItem IN THIS.Lines.OldItem ? oItem.Product.Code,oItem.Product.Description, oItem.Quantity ENDFOR ENDPROC ENDDEFINE |
|
|
Send feedback on this topic to RunAhead Technologies For Technical support and product issues please contact us at support@foxdataobjects.com or visit http://www.foxdataobjects.com |
Copyright (c) 2000-2005 RunAhead Technologies