Actually it's never the inline query strings that cause problems for me. It's usually more serious problems since NHibernate is decent with the type of exceptions thrown.
On Mon, Feb 22, 2010 at 8:41 PM, nadav s <[email protected]> wrote: > first of all, you can use constants > if not, you can use named queries so that the queries will compile on the > factory initialization, and you won't get sudden runtime errors (its still > runtime but its on the initialization) > > On Mon, Feb 22, 2010 at 9:06 AM, Peter4922 <[email protected]>wrote: > >> Hi, >> >> thanks for the reply. >> >> Is there any good way to avoid having to hard code the class names >> DownLoad and the property name DateTime ? How does one avoid errors >> when changing the property names and the query stops working ? >> >> Regards >> >> Peter >> >> On Feb 19, 6:08 pm, Fabio Maulo <[email protected]> wrote: >> > session.CreateQuery("delete from DownLoad d where d.DateTime > >> > :fromDate").SetDateTime("fromDate", fromDateTime).ExecuteUpdate(); >> > >> > 2010/2/19 Peter4922 <[email protected]> >> > >> > >> > >> > >> > >> > > Hi, >> > >> > > what is the recommended way to delete multiple records that have not >> > > previously been read from the database using CreateCriteria ? >> > >> > > This is what I do: >> > >> > > //first get all the downloads with DateTime >= fromDateTime. >> > > IList<Download> downloads = session >> > > .CreateCriteria(typeof(Download)) >> > > .Add(Restrictions.Gt("DateTime", fromDateTime)) //DateTime >> > > > fromDateTime. >> > > .List<Download>(); >> > >> > > //now delete the downloads >> > > foreach (Download download in downloads) >> > > { >> > > session.Delete(download); >> > > } >> > >> > > Is there any way using CreateCriteria to do this in one call. Is >> > > session.Delete("from Download d where d.DateTime >"+fromDateTime) the >> > > only way ? >> > >> > > Kind regards >> > > Peter >> > >> > > -- >> > > 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]> >> <nhusers%[email protected]<nhusers%[email protected]>> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/nhusers?hl=en. >> > >> > -- >> > 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]<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]<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.
