NHibernate查询与时间戳字段过滤 [英] NHibernate query with filter by timestamp field

查看:172
本文介绍了NHibernate查询与时间戳字段过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有Timestmap类型的版本控制字段的表.现在,我尝试通过该字段进行搜索查询,但是当我以另一种方式传递参数时:

I have table with versioning field of type Timestmap. Now I'm trying to make a query with search by this field, but when I'm passing parameter in next way:

query.SetParameter("TimeStamp", lastTick, NHibernateUtil.Timestamp);

将其作为DateTime传递给sql查询.还尝试了NHibernateUtil.Binary,但是nhibernate将其作为varbinary传递.

it pass it as DateTime to the sql query. Also tried NHibernateUtil.Binary, but nhibernate pass it as varbinary.

推荐答案

NHibernate TimestampType指定:

The NHibernate TimestampType specifies:

这与DateTime几乎完全相同,但可以使用 在版本列中,将其存储到数据库支持的精度, 并将默认为DateTime.Now的值.如果该值为null.

This is almost the exact same type as the DateTime except it can be used in the version column, stores it to the accuracy the database supports, and will default to the value of DateTime.Now if the value is null.

该类型根本不能与MS SQL类型TIMESTAMP一起使用.实际上,该列类型已被弃用:

This type is simply not for use with the MS SQL type TIMESTAMP. In fact, that column type is deprecated:

不建议使用时间戳语法.将来的Microsoft SQL Server版本将删除此功能.避免在新的开发工作中使用此功能,并计划修改当前使用此功能的应用程序.

The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

行版本(Transact-SQL)

您应该使用NHibernateUtil.BinaryNHibernateUtil.BinaryBlob.

这篇关于NHibernate查询与时间戳字段过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆