TypedListDAO, et al - Why So Many That Do the Same Thing?

Posts   
 
    
vm0112
User
Posts: 5
Joined: 15-Jun-2018
# Posted on: 16-Jun-2018 17:51:52   

I have to assume I’m missing something. My generated project has the usual TypedListDAO along with xxxDAO for each entity in the project.

It seems to me that any DAO can be used to consume any dynamic query and none of them appear to have public properties related to the entity they come from (I see there is something internally but they’re not exposed) - therefore they cannot be used like TypedListRow objects or any other DTO. Each DAO seems to be just a mechanism to consume a DynamicQuery.

What I was assuming is that if I want a typed resultset, I would be able to use one of the corresponding DAOs that matches the entity I’m working with. It only makes sense. If I want a typed resultset that includes ALL fields, I thought these DAOs would work similar to TypedListRows. But they don’t seem to work this way.

Of course, I can create a typed list that has every field from every entity they come from from, but that seems like a lot of work to simply get every field. Yes, I can hand-code my own DAO with the fields I want, I can do a lambda that returns an anonymous, and yes I can do an entity fetch (but I don’t want to do that as they’re more heavyweight and don’t serialize in self-servicing).

So, I found that if I have this:

//StatesTypedListRow is from a TypedList.
var c7 = new StateDAO().FetchQuery(qf.Create().Select<StatesTypedListRow, StateFields>());

it can be replaced with this:

var c7 = new TypedListDAO().FetchQuery(qf.Create().Select<StatesTypedListRow, StateFields>());

So if this is the case, why have so many DAOs that appear to do the same thing except have different names?

Also, I originally tried this as if each DAO was also a DTO (I just wanted a typed result):

//StateDAO is generated by LLBLGEN
var c7 = new StateDAO().FetchQuery(qf.Create().Select<StateDAO, StateFields>());

as well as every other possible way and none of this works.

As far as I can see, I can use the TypedListDAO for everything and every other DAO is redundant. Every DAO is NOT a DTO. Any help clearing this up would be appreciated.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jun-2018 07:27:59   

vm0112 wrote:

I have to assume I’m missing something. My generated project has the usual TypedListDAO along with xxxDAO for each entity in the project.[]

It seems to me that any DAO can be used to consume any dynamic query and none of them appear to have public properties related to the entity they come from (I see there is something internally but they’re not exposed) - therefore they cannot be used like TypedListRow objects or any other DTO. Each DAO seems to be just a mechanism to consume a DynamicQuery.

TypedListDAO class, exposes the functionality to fetch a set of data in a DataTable object, logic which is also used by every TypedList's Fill() method. It also has logic to execute plain SQL, along other DB-related functionalities. This is used a lot because is very flexible and can be easily extended with expressions for complex resultsets, for example for usage in reports. The xxxDAO variant uses a lot of this generic version TypedListDAO, but it exposes methods to fill specific objects, like custom typedlists.

vm0112 wrote:

What I was assuming is that if I want a typed resultset, I would be able to use one of the corresponding DAOs that matches the entity I’m working with. It only makes sense. If I want a typed resultset that includes ALL fields, I thought these DAOs would work similar to TypedListRows. But they don’t seem to work this way.

What do you mean? Please elaborate more on what do you expect and how are you using the objects.

vm0112 wrote:

As far as I can see, I can use the TypedListDAO for everything and every other DAO is redundant. Every DAO is NOT a DTO. Any help clearing this up would be appreciated.

For more general operation you just need TypedListDAO. DAO is not DTO, that's right. Each xxxDAO has specific information to build the entity/typedlist/typedview information specific to an object. For instance: the relations and how to build them in sql.

David Elizondo | LLBLGen Support Team