It's a bad idea. But you answered yourself: you can do it in the DTO, thus
simplifying the query and reducing the server load. Win-win.

    Diego


On Fri, Sep 10, 2010 at 11:11, bdaniel7 <[email protected]> wrote:

> Hello,
>
> I'm loading a DTO who's properties are mapped on the tables' columns
> and one property is calculated from the others.
>
> with SQL:
> SELECT
>        ud.DateOfReading
>        , ud.IdleTime
>        , ud.SavingsTime
>        , ud.SaveSetting
>        , (ud.SavingsTime * ud.SaveSetting/ud.IdleTime * 0.7) as SaveScore
>
> is it possible to define that formula in the ICriteria's projections?
>
> with ICriteria:
> .SetProjection( Projections.ProjectionList()
>        .Add( Projections.Property( "DateOfReading" ), "DateOfReading" )
>        .Add( Projections.Property( "IdleTime" ), "IdleTime" )
>        .Add( Projections.Property( "SavingsTime" ), "SavingsTime" )
>        .Add( Projections.Property( "SaveSetting" ), "SaveSetting" )
>        )
>        // set the transformer
>        .SetResultTransformer( Transformers.AliasToBean( typeof(
> SaveScoreDTO ) ) )
>        .List<SaveScoreDTO>();
>
> I know that I could calculate the SaveScore in the DTO, but I thought
> I'd let the SQL server do it.
>
> Thank you,
> Daniel
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to