本文介绍了Nhiberante - CreateSqlQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有使用WPF和NHiberante的项目
它使用数据库Oracle和Sql
我在CreateSQlQuery()中遇到错误/>
声明如下:
它正在使用sql数据库,但在Oracle Databse中出错了
I have project using WPF and NHiberante
it use both database Oracle and Sql
I got error in CreateSQlQuery()
Statement is given below
it is working on sql Database but get error in Oracle Databse
var Query = session.CreateSQLQuery(string.Format(SELECT * FROM Users WHERE UserCode ='admin' AND PASSWORD = '123'
UNION
SELECT * FROM Users WHERE UserId IN (SELECT UserRoleId FROM UserRole WHERE UserId = (SELECT UserId FROM Users WHERE UserCode = 'admin' AND PASSWORD = '123' ))ORDER BY RecordType DESC, UserCode, Password))
如果我像下面这样编写这个查询。它正在处理Oracle数据库但不能处理sql数据库。
if I write this query like below.it is working on Oracle db but not working on sql Database.
var Query = session.CreateSQLQuery(string.Format(SELECT * FROM(SELECT * FROM Users WHERE UserCode ='admin' AND PASSWORD = '123'
UNION
SELECT * FROM Users WHERE UserId IN (SELECT UserRoleId FROM UserRole WHERE UserId = (SELECT UserId FROM Users WHERE UserCode = 'admin' AND PASSWORD = '123' )))ORDER BY RecordType DESC, UserCode, Password))
我需要一个查询同时处理Databse 。
如果有人可以帮助我..
I need one query working on both Databse .
If any one can help me..
推荐答案
var Query = session.CreateSQLQuery(string.Format(SELECT * FROM(SELECT * FROM Users WHERE UserCode ='admin' AND PASSWORD = '123'
UNION
SELECT * FROM Users WHERE UserId IN (SELECT UserRoleId FROM UserRole WHERE UserId = (SELECT UserId FROM Users WHERE UserCode = 'admin' AND PASSWORD = '123' )) temptbl ORDER BY RecordType DESC, UserCode, Password))
快乐编码!
:)
Happy coding!
:)
这篇关于Nhiberante - CreateSqlQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!