isqlquery

Ignore parameters when using ISQLQuery in NHibernate

北城余情 提交于 2020-02-06 03:38:02
问题 I have to execute a native sql statement with NHibernate to the database. For this, i use: var query = session.CreateSQLQuery(sql); query.ExecuteUpdate(); Now, the sql contains the character : in a Column-Alias (which I need on this way) and NHibernate is handling this with a parameter. I haven't any parameter in this sql statement. Can I define somewhere, that NHibernate should not manage parameters for this ISQLQuery? 回答1: Just use native connection for native SQL execution: var cmd =

Ignore parameters when using ISQLQuery in NHibernate

狂风中的少年 提交于 2020-02-06 03:36:31
问题 I have to execute a native sql statement with NHibernate to the database. For this, i use: var query = session.CreateSQLQuery(sql); query.ExecuteUpdate(); Now, the sql contains the character : in a Column-Alias (which I need on this way) and NHibernate is handling this with a parameter. I haven't any parameter in this sql statement. Can I define somewhere, that NHibernate should not manage parameters for this ISQLQuery? 回答1: Just use native connection for native SQL execution: var cmd =

JOIN three tables and aggregate data from multiple rows for every DISTINCT row in separate column

我们两清 提交于 2019-12-11 17:27:35
问题 JOIN three tables and aggregate data from multiple rows for every DISTINCT row in separate column i have a table where one item is mapped with multiple items. Key 1 | Key 2 1 2 1 5 1 6 1 4 1 8 I have another table like this Key 1 | ShortKey1Desc 1 'Desc short' i have one more table where i have data like this Key 1 | Description 1 'Desc a' 1 'Desc c' 1 'Desc aa' 1 'Desc tt' i need to write a sql query for my view where table would be generated like this Key 1 | AllKeys2ForKey1 |

SQL query selecting between two dates

点点圈 提交于 2019-12-11 03:21:46
问题 I want to select records between two dates - a startDate and endDate (they are date/time format in sql). I have the following sql query but it does not work, could someone tell me what I'm doing wrong? "SELECT * FROM house WHERE startDate >= '2012/02/22 00:00:00' AND endDate <= '2012-02-25 00:00:00'" 回答1: I would suggest converting the dates to a datetime and comparing them as well as keeping the date standard and consistent. Something like: "SELECT * FROM house WHERE DATE(startDate) >= DATE(