andieje wrote:
Hi
I'm sorry about my choice of language. I did not mean to offend. I am grateful for your help.
I am evaluating llblgen pro with a view to buying it and I am frustrated by the lack of a sample asp.net application containing examples of common functions such as sorting/paging/editing.
The framework has a tremendous amount of functionality. Thus this leads to a thick manual, that's unavoidable. The manual is setup in such a way that with many items discussed a code snippet illustrates whats been explained. For example sorting.
We have an ASP.NET example application, called petshop, which illustrates paging for example. Sorting is explained in the manual and also in other sample applications: an entity collection isn't different in an ASP.NET application as it is in a windows forms application.
Back to your reply.
You are correct that I could come up with a routine myself. However, what I would rather see is a tried and tested way of doing something that has been devised by an expert in the area. My way may well be inefficient or convoluted. It normally is. In fact the way I was thinking of doing it isnot the way you demonstrated.
This is how i would do it:
Dim orders as OrdersCollection
orders.getMulti(nothing) 'this has all orders
'To get the orders for a specific customer
dim customerOrders as OrdersCollection
customerOrders = orders 'copy all orders over
customerOrders.getMulti(add some filter here that filters by customer)
Id your way quicker/better? I presume getMulti is just doing what you do behind the scenes anyway
The hard part of working with databases and code which targets databases is that there's no clear way to do something in all situations so it always works or always is efficient.
There are two things: working in-memory with data and working with the data in the database. Working with data in-memory is always slower per operation than working with data in the database. However reading data from the database, reading it into objects etc. also takes time. So it can be that if you have 10 orders in a collection, and you want to filter them on a customerid, it could be it's more efficient to simply walk the collection in an O(n) operation than go back to the database, fetch the entities requested, load these into new entity objects etc. That could be slower, if the table contains a lot of data.
though in general, filtering in memory is an O(n) operation, which means all objects have to be examined. So if you first fetch ALL data, then traverse ALL that data in-memory, it will be slow. If you filter on the database, fetch only the data you need, it's much faster, in most cases, but as I said: it can be it's slower if the n is small and the table is big (or for example you have to fetch the data from a webservice etc. )
Rule of thumb: always fetch AT MOST the data you need at that given moment. So don't fetch a large set of data and then traverse it to filter out what you want to use.
Your example is also inefficient because you fetch all orders which aren't used. GetMulti() works on the database: it produces a query on the db, not an in-memory filter.