To clarify, this is the issue:
For this mapping:
<subclass name="Visit"> <property name="IsFixed" column="`Fixed?`" />
</subclass>
Running this query:
return _session.CreateQuery("select visit from Visit
visit").List<Visit>();
Generates this SQL:
select visit0_.[Fixed@p0] as Fixed14_22_ from dbo.tblVisits visit0_
Which results in SqlException Invalid column name 'Fixed@p0'.
This appears to be a bug in NHibernate 3.1, issue has been raised.
http://stackoverflow.com/questions/5805617/escaping-a-question-mark-character-in-a-column-name-in-nhibernate
On Apr 27, 4:20 pm, Martin Ingham <
ingham.mar...@gmail.com> wrote:
> Sorry, just realized you specified backticks. Tried this also,
> doesn't work.
>
> On Apr 27, 12:06 pm, Martin Ingham <
ingham.mar...@gmail.com> wrote:
>
> > I did, this does stop the parameter replacement but the SQL generated
> > is now looking for a column called 'Fixed?' including the single
> > quotes, which results in an error from the DB server (MS SQL Server
> > 2008 R2). I had tried to get round the problem by requesting the
> > column be renamed to remove thequestionmarkbut this option is
> > proving to be more difficult than I'd anticipated.
>
> > On Apr 11, 8:59 am, Juan Carlos <
jcsegu...@gmail.com> wrote:
>
> > > Did you try it with [`Fixed?`]
>
> > > Kind regards
>
> > > El 08/04/2011 13:12, Martin Ingham escribió:
>
> > > > I haven't been able to find the answer to this in any NHibernate
> > > > documentation. I am trying to write an HQL query with named
> > > > parameters. Unfortunately one of the column names includes aquestion
> > > >markcharacter in its name. In the mapping file I have wrapped the
> > > > column name in square brackets which works fine for ICriteria
> > > > queries. But when constructing the SQL statement NHibernate seems to
> > > > interpret thequestionmarkas a position parameter placeholder even
> > > > though it's inside the square brackets, so it ends up substituting the
> > > >questionmarkwith the parameter i.e. the query winds up containing
> > > > this column:
> > > > visit0_.[Fixed@p0]
> > > > whereas the column should be visit0_.[Fixed?]
> > > > Does anyone have any ideas how aquestionmarkpolluted column name