Find this post:
Page Cannot Be Found - DNS Error
Tuesday, January 31, 2006 4:55 PM
and check my 2 replies.
...
To add to your discussion:
You could.
When a Product is requested:::(say productid = 123 for example)
1. If your ProductCollection doesn't exist, then create it.
2. If your ProductionCollection exists.. then check it to see if it has
Product with ProductID = 123
3. If so, then return it.
4. If not, call a another class to read the database, create an
IDataReader, and return the Product
5. .Add it to your ProductCollection
6. ?Re-persist our Collection.
...
Or you can get the whole shooting match of products, and put them in your
ProductCollection.
That is an architectural decision you'll have to make. It depends on if
people are accessing most of your products (where i'd put them all in the
Collection up front) OR.. .they access a few of them more often. (I'd do
the 6 steps above).
...
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:u6**************@TK2MSFTNGP15.phx.gbl...
at the moment i do it like you...
every time a article is "loaded" (an object ist created), the values for
the properties are fetched from the database.
If i create many objects of the class "article" then there are many
datasource.open() and datasource.close() operations.... and there is for
every article a SELECT-operation.
isn't that inefficient? or doesn't matter that?
"Dan" <dv*******@aol.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP14.phx.gbl... Like you would with any application, why do you think it would be
different because it is a shop? Database is a database regardless of
what it stores.
So as and when you need info from the db open a connection, run your
sql, close it straight away.
I personally made a wrapper class with all my db functionality, that way
i could do something like:
dbClass _dbObj = new dbClass();
int _productid;
float sellingPrice = _dbObj.GetProductPrice(_productid);
and so on... Makes life much easier, then if you change your db
structure all your sql commands are in that db class and you need only change them
there.
--
Dan
"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> wrote in
message news:Ou**************@TK2MSFTNGP09.phx.gbl... Hi,
I have a database with 40000 articles... (it is a shop) ... there are
columns like price, stock, name, short description, long description
etc.... the long description could be really much text.
How would you programm the connection to the database in a
shopapplication?
1. DataSet with all articles (and all data) in it for every user of the
webpage?
2. Class "article" (with properties price,stock,name,... )
2.1. get the values of the properties on first use (connect everytime
for every property to database and fetch it)
2.2. get all values for the article in advance (on creation of an
object of the class)
3. another (which?) way?
Which solution would you choose?
Thanks a lot
alex