开发者

Compare datetime property to certain date via HQL (.Net)

开发者 https://www.devze.com 2023-01-03 07:29 出处:网络
I have problems comparing the datetime property of objects and when trying to compare to a given date. For example, I tried

I have problems comparing the datetime property of objects and when trying to compare to a given date. For example, I tried

 IQuery query1 = session.Cr开发者_运维百科eateQuery(String.Format(
            @"Select s.Id  
            From InventoryProductStateItem s
            Where s.ValidFrom = " + stateItem.ValidFrom));

but get an exception "Incorrect syntax".


Dates can be compared by passing a parameter to the query:

IQuery query1 = session.CreateQuery(String.Format(
            @"Select s.Id  
            From InventoryProductStateItem s
            Where s.ValidFrom = :stateDate)")).SetParameter("stateDate", state.ValidFrom);
0

精彩评论

暂无评论...
验证码 换一张
取 消