C# Composite pattern and Database Access -
Assuming that I have a composite class pharma product (which is the product of a pharmaceutical company The hierarchy shows) And for this, in the database table, I have thought of loading data in two ways in the pharma product object.
(1) Create an entire object-paste when the object is instatable. Make changes in the tree and continue these changes by applying a recursive loop to the tree (it actually works like C # Dataset ).
(2) Load a node only when the other nodes are loaded
Pharma product gateparents () Or,
list & lt; PharmaProduct & gt; GetChldren () (which actually access the direct database) Change the node to save only that node.
This type of tables can have a thousand entries, depending on how many types of drugs a company makes. So in that case, the first approach would be very unnecessary (and even memory consumption) I think.
How do I use the database in case of any overall pattern problem? Take a look at the
proxy pattern, you can use PharmaProductProxy puts objects in Paste, which holds the same interface as PharmaProduct , but lazy ones themselves access.
Comments
Post a Comment