-1

I have a table with columns that have colons within. I am trying to figure out a way to ignore the colon as a parameter when trying to query the DB. I have tried to use SetParameter and String.Format but it does not work. I have also tried to escape the colon with a :: and \ but no luck. See a sample below

var result = session.CreateSQLQuery("Select id, [Results: A] as ResultsA, [Results: B] as ResultsB FROM Table").SetResultTransformer(Transformers.Alias.ToBean<TableObject>()).List<TableObject>();
TheProgrammer
  • 1,314
  • 5
  • 22
  • 44

2 Answers2

1

You have to escape colons and \ too.

Try to replace : by \\:

Alternatively, you can add @ before your string to avoid \\

like this:

var result = session.CreateSQLQuery(@"Select id, [Results\: A] as ResultsA, [Results\: B] as ResultsB FROM Table").SetResultTransformer(Transformers.Alias.ToBean<TableObject>()).List<TableObject>();
Swisstone
  • 220
  • 3
  • 13
  • No luck, when I use the @ or the \\: it makes the query Select id, [Results\\: A] as ResultsA, [Results\\: B] as ResultsB FROM Table, but it still sees the colon as a parameter – TheProgrammer Oct 04 '19 at 20:57
0

Check the exception details, and SQL that is actually send to DB.