Nevermind, found sql-query tag in mappins... which worked fine.

On 18 Okt, 15:18, devghost <[email protected]> wrote:
>  Hi,
>
> Is it possible to use Expression.Sql to assign a value to a property?
>
> I have mapped two tables to their respective classes, but now I need
> an aggregate value from a column in a third table. To get a hold of
> this
> table I would need to join another 5 tables, this seems like too much
> work
> for a single column. I am therefore looking for other options, one
> being
> to use Expression.Sql. But I do not know if this is the best solution
> or
> even if it is possible.
>
> This is a trimmed down version of the code I have today...
>
> var deliveries = Session.CreateCriteria<ObjectDelivery>()
>                         .Add(Restrictions.Between("LoadingDate",
> filterStartDate, filterEndDate))
>                         .AddOrder(new Order("LoadingDate", true))
>                         .List<ObjectDelivery>();
>
> What I would like to do is to add something similar to the following
> line:
>    .Add(Expression.Sql("SELECT PropertyInObjectDelivery =
> Count(tbl.Cloumn) FROM table AS tbl WHERE ..."))
>
> That would add the Count aggregate value into the Property in
> ObjectDelivery.
>
> What is the best way to achieve something like this?

-- 
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