Thanks. This way it's clear. I just didin't understand the pCheck thing from Fabio because of the missing ":" infront of the parameter - so I thought it must be someting from SQL or NHibernate
Thanks for your explication On 17 Feb., 11:34, Germán Schuager <[email protected]> wrote: > Just add another paramter and set it to true if you want to allow nulls, or > false if you don't: > > "from Table where Status = :s or (:canBeNull = 1 and Status is null)" > > session.GetNamedQuery("queryName") > .SetString("s", "active") > .SetBoolean("canbenull", true) > .List(); > > On Tue, Feb 17, 2009 at 6:39 AM, antoschka <[email protected]> wrote: > > > Thanks a lot. I'm glad that there seems to be a solution. > > Unfortunately I do not understand it :( > > What is pCheck and how do i need to set the parameter in the code for > > either cases. > > so it comes down to the question how to write following line of code > > checking Field for 'myValue' AND null vs. checking it only for > > 'myValue' > > query.SetParameter("something", ???) > > > Thanks a lot for your help antoschka > > On 17 Feb., 03:29, Fabio Maulo <[email protected]> wrote: > > > Sure: pure SQL > > > where (Field = :something and pCheck = 1) or ((Field = :something or > > Field > > > is null) and pCheck = 0) > > > > 2009/2/16 antoschka <[email protected]> > > > > > Hi, > > > > > i use a named sql query an face the situation that I want to set a a > > > > parameter to either one or two values like > > > > > select * > > > > from table > > > > where Status = :parameter > > > > > parameter should be in some cases 'something' in other cases > > > > 'something' or null. > > > > > is teher a way to use one named query for that or do I have to create > > > > two queries and use one for the one-parameter-query ('something')and > > > > the second one fo the two-parameter-query ('something' or null)? > > > > > Thanks fro your help > > > > > antoschka > > > > -- > > > Fabio Maulo > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
