what is the equivelent in a typed list?

Posts   
 
    
Posts: 35
Joined: 22-May-2006
# Posted on: 12-May-2009 00:11:29   

Hi,

I have a SQL Statement:

select name, (datasize/1024/1024) MB  from dtree, dversdata where subtype = 144 and datasize/1024/1024 > 15 and dataid = docid order by datasize desc

How would I accomplish the "(datasize/1024/1024) MB"

Thanks,

Nate

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-May-2009 05:51:57   

Better if you use DynamicLists. Here is an approximate code of the expression part (assuming Adapter TemplateSet):

ResultsetFields fields = new ResultsetFields( 2 );
fields.DefineField( DtreeFields.Name, 0, "Name" );
fields.DefineField( DtreeFields.DataSize, 1, "MB");

IExpression calculationExp = new Expression(DtreeFields.DataSize, ExOp.Div, 2048);
fields[1].ExpressionToApply = calculationExp;

DataTable results = new DataTable();
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchTypedList( fields, results, null );
}
David Elizondo | LLBLGen Support Team
Posts: 35
Joined: 22-May-2006
# Posted on: 12-May-2009 13:58:33   

thanks! I will try it out.

Posts: 35
Joined: 22-May-2006
# Posted on: 13-May-2009 14:30:24   

Hi,

I am able to get it to work, but what I need to do from SQL is (DataSize/1024/1024) AS MB.

IExpression calculationExp = new Expression(DtreeFields.DataSize, ExOp.Div, 2048);

is not the same calculation. How can I apply the logic of (DataSize/1024/1024) AS MB

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 13-May-2009 14:44:21   

These are fixed values, so why don't you just use the following for simplicity:

IExpression calculationExp = new Expression(DtreeFields.DataSize, ExOp.Div, 1048576);

Or for better readability:

IExpression calculationExp = new Expression(DtreeFields.DataSize, ExOp.Div, (1024*1024));
Posts: 35
Joined: 22-May-2006
# Posted on: 13-May-2009 14:48:55   

perfect! thanks!