Does anybody know of any libs that will take a generic list of objects (eg.,. TList) and convert it to a TDataSet so it can connect directly to something like a cxGrid that would require an in-memory dataset otherwise? (I'm aware of one, but I'm curious if there are others.)

Comments

  1. Sorry, I was taking about what you asked (plus more :) ) but I used the term ORM for mapping memory dataset to objects and vice versa.
    For your specific question spring4d has TObjectDataset but AFAIK has some problems with filtering and sorting.
    Also it's very important to specify in your question if you need dual binding (synch) or only one binding objects -> dataset.
    Also keep in mind if you need dual binding, with TObjectDataset you can't write validation code in OO because TObjectDataset synch with objectList in AfterPost method.

    ReplyDelete
  2. Emil Mustea what I'm asking about is binding something like a TList to a TDBGrid. In this case, any actual dataset that may be involved is incidental. It's the list of TObjects in this case that are being loaded and stored from/to the DB directly. This is not the typical usage pattern.

    DB <-A-> TList <-B-> TDBGrid

    The problem is that containers like TList are not "data-aware". A regular TDataset is used to access the DB in normal fashion to effect channel 'A'.

    But how do you implement channel 'B' without either: (1) making an adapter for TList to look like a TDataset, or (2) stuffing a real TDataset like a memory table into the channel to connect with the grid?

    It looks like Spring4D, for example, uses approach (1). The ORMs probably do as well, although it's not entirely clear.

    I employed (2) in my case by using a memory table. Yes, it effectively becomes a cache, with all of the consequent cache-related issues that come along with that. But it's certainly not a new problem.

    What I've found was that the existing adapters I've seen for approach (1) tend to be limited to working with specific types of lists. Some only take a TObject and build their own lists. I guess Spring4D doesn't care because it uses an Interface. The full-blown ORMs also seem to work with individual objects as well, not lists (in addition to DBs).

    It has been interesting shining a light on this. My thanks to everyone!

    ReplyDelete
  3. If you use cxGrid you can write your own TcxCustomDataSource (as Larry Hengen said). Anyway the best/flexible solution you already choose is memory dataset.

    ReplyDelete

Post a Comment