DataView or DataTable?

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 28-Dec-2010 06:57:57   

Hi everybody, we have a web project that uses the business layer (BL) to generate all entity related methods such as create, delete, update and get. In some cases we do create dataviews collecting fields from several related entities just like the HnD project itself does.

One of my colleague insists on returning datatables instead of dataviews. To my knowledge there isnt much difference between the two, dataviews are sortable, supports filter etc, and you may add columns to datatables and create several dataviews from the same data table...And datatables are serilizable where dataviews are not.

The question is: what do you think? does using datatable have any advantages or disadvantages? Since the BL produces the datatable or the dataview and gui uses it, does exposing datatable to the gui that resides on a remote server has any kind of security risk over dataview?

Or anything else you would wanna add? thanks

-shane

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39753
Joined: 17-Aug-2003
# Posted on: 28-Dec-2010 10:02:02   

A datatable is the source of a dataview. A dataview therefore always references a datatable, as it is the source of the data viewed through the dataview.

So returning 'dataviews' is really not different from returning 'datatables', they both contain the datatable. The difference can be that if you pre-filter dataviews, and then return them, you can avoid doing that in the calling code, but that's about it.

Binding a datatable to anything always results in binding the default dataview to the control instead.

Frans Bouma | Lead developer LLBLGen Pro
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 28-Dec-2010 21:20:03   

Otis wrote:

A datatable is the source of a dataview. A dataview therefore always references a datatable, as it is the source of the data viewed through the dataview.

So returning 'dataviews' is really not different from returning 'datatables', they both contain the datatable. The difference can be that if you pre-filter dataviews, and then return them, you can avoid doing that in the calling code, but that's about it.

Binding a datatable to anything always results in binding the default dataview to the control instead.

I understand, thank you.

So in terms of security, performance or usability there isnt really any difference between the two if we are not doing any kind of pre-filtering - since one may be converted into another easily?

Or any specific reason why you've almost always returned the default view of the generated datatable and not the datatable itself in HnD?

-shane

Walaa avatar
Walaa
Support Team
Posts: 14984
Joined: 21-Aug-2005
# Posted on: 29-Dec-2010 10:21:51   

The DataView is the object used in databinding. Other than that there is no subtle difference between them.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39753
Joined: 17-Aug-2003
# Posted on: 29-Dec-2010 10:54:59   

We return the view for semantic purposes: it's the set of data to use, the caller should simply use that instead of the underlying datatable which might be usable to add rows (but which will never be processed), as the set of data is to be used as readonly.

Frans Bouma | Lead developer LLBLGen Pro
allenwd4x
User
Posts: 1
Joined: 10-Jan-2011
# Posted on: 10-Jan-2011 13:27:00   

Otis wrote:

A datatable is the source of a dataview. A dataview therefore always references a datatable, as it is the source of the data viewed through the dataview.

So returning 'dataviews' is really not different from returning 'datatables', they both contain the datatable. The difference can be that if you pre-filter dataviews, and then return them, you can avoid doing that in the calling code, but that's about it.

Binding a datatable to anything always results in binding the default dataview to the control instead.

Thanks for the infomation provided by you...Actually I too was not knowing this. I am new to this forum and I got such an info . I am happy to be a part of such amazing forum.