I am building c# application that deals with a legacy database based on MSAccess.
There is a table that has a GUID type (Numeric defined as Replication ID).
I tried with many options to map a .NET poco to that table, with not success.
All what I want is to insert into a table.
so, I thought I will just pass a straight sql statement.
I tried this statement, and it worked fine if I run it from within MSACESS sql
insert into message (PK_ID, To) values ({guid {a033df0a-2e0c-4085-a022-e60767e402a4}}, 'myemail@yahoo.com')
But when I run it from c# using NHibernate’s CreateQuery.ExecuteUpdate()
I will get the following error
HQL: insert into message (PK_ID, To) values ({guid {a033df0a-2e0c-4085-a022-e60767e402a4}}, ‘myemail@yahoo.com’)
line 1:41 no viable alternative at character ‘{‘
line 1:44 no viable alternative at character ‘{‘
And the exception is from ANTLR
Any idea?
CreateQuerycreates a NHibernate query which expects HQL syntax and{guid {a033df0a-2e0c-4085-a022-e60767e402a4}}is not valid HQL. If you want to execute a raw SQL query you need to useCreateSQLQuery.