Found this in NHibernate.Test.Linq.LinqQuerySamples:
[Ignore("TODO - nested select")]
public void DLinq17()
{
...
var q =
from o in db.Orders
select new
{
o.OrderId,
DiscountedProducts =
from od in o.OrderLines
where od.Discount > 0.0m
select od, FreeShippingDiscount = o.Freight
};
...
}
Guess it's not implemented then.
On Tue, May 25, 2010 at 11:35 PM, Martin Nilsson <[email protected]>wrote:
> Hi,
>
> I want to create an object from a NH Linq query
> var orderDetails = (from order in session.Query<Order>()
> where order.OrderNumber == orderNumber
> select new OrderDetails(order.OrderNumber,
> order.OrderItems.Select(i
> => new OrderDetails.OrderItemDetail(i.Id, i.Name))))
>
> But getting below error for "order.OrderItems.Select(..)"
>
> ERROR NHibernate.AdoNet.AbstractBatcher - Could not execute query:
> select order0_.OrderNumber as col_0_0_, (select orderitems1_.Id,
> orderitems1_.Name from "OrderItem" orderitems1_ where
> order0_.OrderNumber=orderitems1_.Order_id) as col_1_0_ from SalesOrder
> order0_ where order0_.ordernumb...@p0 limit 1
> System.Data.SQLite.SQLiteException: SQLite error
> only a single result allowed for a SELECT that is part of an
> expression
>
> Any ideas how I can write this query so that I can create OrderDetails
> (Dto)?
> public OrderDetails(int orderNumber, IEnumerable<OrderItemDetail>
> orderItems)
>
> Sure I can change ctor to public OrderDetails(int orderNumber,
> *IEnumerable<OrderItem>* orderItems) but I would first like to try
> with IEnumerable<OrderItemDetail>
>
> I'm using NH trunk
>
> /martin
>
> --
> 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.