I answered my own question, I think.  I couldn't figure out how to do
it with HQL or a Criteria query, so I resorted to a SQL query:

string querytext = "SELECT p.* FROM Product p " +
    " INNER JOIN ProductTag t0 ON p.ProductID = t0.ProductID AND
t0.TagID = 1" +
    " INNER JOIN ProductTag t1 ON p.ProductID = t1.ProductID AND
t1.TagID = 2";

I just add another INNER JOIN line for each tag.  My code to get the
products looks something like this:

ISQLQuery q = sess.CreateSqlQuery(querytext).AddEntity(typeof
(Product));
IList<Product> prodlist = q.List<Product>();

This seems to work very well, but I haven't done any stress loading on
it to see if it scales at all.  If I'm headed down the wrong path,
feel free to smack me about the head several times (virtually, that
is).

Todd

P.S.  I'm concerned about "hard coding" the table names into my SQL.
Is there an (easy) way to get the table name that is mapped to a given
type?


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