Calculated properties

Posts   
 
    
rasmus
User
Posts: 5
Joined: 12-Jan-2005
# Posted on: 27-Jan-2005 21:00:20   

Hi,

I have seen some posts about calculated properties, but I still cant figure out how to perform a query like this:


SELECT 
Reserventid, Number, Moved,
(R.Creationdate + (365*R.Duration)) as Duedate 
FROM dbo.[Reservent] as R

If anybody knows the answer could you please post some code to document it(pref. C#).

At the moment I am stuck with Dyn. List since I dont know how to add a IExpression to a field I define.

Thx.

Rasmus

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Jan-2005 21:42:06   

ResultsetFields fields = new ResultsetFields(3); fields.DefineFiend(...); // ...

add an expression to a field: fields[index].ExpressionToUse = myExpression;

If this won't give you the results planned, I'll work out your example tomorrow.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-Jan-2005 11:03:42   

ResultsetFields fields = new ResultsetFields(4);
fields.DefineField(ReserventFieldIndex.ReserventId, 0, "ReserventId");
fields.DefineField(ReserventFieldIndex.Number, 1, "Number");
fields.DefineField(ReserventFieldIndex.Moved, 2, "Moved");
fields.DefineField(ReserventFieldIndex.Creationdate, 3, "Duedate");
IExpression expr = new Expression(
    EntityFieldFactory.Create(ReserventFieldIndex.CreationDate),
    ExOp.Add,
    new Expression(
        356,
        ExOp.Mul,
        EntityFieldFactory.Create(ReserventFieldIndex.Duration)));
fields["DueDate"].ExpressionToUse = expr;

// use the fill code for typed lists to fill this dyn. list:
DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, null, null, null, true, null, null, 0, 0);

Frans Bouma | Lead developer LLBLGen Pro