Hello!
I need to get a customers last Order with all it's OrderLines, each line
with it's Article in one go.
so the generated (ms) sql would be
WHERE (this_.UserID = '18080') AND (this_.Timestamp =
(SELECT MAX(Timestamp) AS y0_
FROM Orders AS this_0_
WHERE (UserID = '18080')))
my criteria for this case currently are...
var crit = session.CreateCriteria(typeof(Order))
.SetFetchMode("Lines", FetchMode.Join)
.SetFetchMode("Lines.Article", FetchMode.Join);
crit.Add(Restrictions.Eq("Customer.Id", customerId));
var clientsMaxTimestamp = DetachedCriteria.For<Order>()
.SetProjection(Projections.Max("Timestamp"))
.Add(Restrictions.Eq("Customer.Id", customerId));
crit.Add(Subqueries.Eq("Timestamp", clientsMaxTimestamp));
but this produces
SELECT ...
FROM ...
WHERE this_.userid = ?
AND ? = (SELECT *Max*(this_0_.TIMESTAMP) AS y0_
FROM orders this_0_
WHERE this_0_.userid = ?)
Positional parameters: #0>18080 #1>Timestamp #2>18080
so the second param (I don't actually want) is "Timestamp", but it is
not a value but a column!
What is it I am erring here at?
--
Jan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---