You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Bjorn I <be...@rocketmail.com> on 2008/05/08 20:18:49 UTC

Complex properties

I'm trying to figure out the best way of returning my list of items to populate a gridview in .Net.
I have a table of items that contains among others a CreateUserID and LastUpdateUserID, each a foreign key to the user table.
I've created an item class that has 2 attributes of the user class. For the front end, I would only need to display first name and last name, the rest of the user data is unecessary.
The user info will not change very often, so I figured I could cache a user select statement. Or should I just do a simple join to get the first name and last name? 
My table contains other foreign keys, such as StatusID etc. In previous applications I would simply add a field to the class that can hold the text representation of StatusID, and use a join in the sql statement, so I could easily bind the result to a .net control. 
In your oppionion, what is the best approach here? I have several pages that will need to display tabular data, each having foreign key relations.
Bjorn


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Re: Complex properties

Posted by Juan Pablo Araya <ju...@gmail.com>.
Hi. For that case, you have two options:

- Filling the gridview with an object data source: in this case you
can create dirty classes that expand your base class (for ex: with
get, set propertys for FirstName, LastName). Using this, just use
joins in your iBatis.

- Filling with a datatable. In this case you must create an utilities
class that returns a DataTable. Filling in the gridview is the same as
in the ObjectDS. In this Grid you can configure the data from your
datatable, so in your method you can put whatever you want (fill the
rows with iList returned through iBatis, iterate through the list and
foreach record fill another rows with aditional data, like First Name,
Last Name, another things, etc.)

We decided to use the datatable because of his flexibility, sorting
and paging properties (the object data source AFAIK does not support
this features) and no use of dirty classes. The only problem I though
is the optimization: the datatable needs to iterate through the iList
and fill the rows, then the gridview iterates again. With the object
data source the iteration is just made once, and internally the
filling (I suspect) is much more efficient.

Greetings and sorry for my poor english!

2008/5/8 Bjorn I <be...@rocketmail.com>:
> I'm trying to figure out the best way of returning my list of items to populate a gridview in .Net.
> I have a table of items that contains among others a CreateUserID and LastUpdateUserID, each a foreign key to the user table.
> I've created an item class that has 2 attributes of the user class. For the front end, I would only need to display first name and last name, the rest of the user data is unecessary.
> The user info will not change very often, so I figured I could cache a user select statement. Or should I just do a simple join to get the first name and last name?
> My table contains other foreign keys, such as StatusID etc. In previous applications I would simply add a field to the class that can hold the text representation of StatusID, and use a join in the sql statement, so I could easily bind the result to a .net control.
> In your oppionion, what is the best approach here? I have several pages that will need to display tabular data, each having foreign key relations.
> Bjorn
>
>
>      ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>