我有一个时间戳列的表(的RowId
)在我的SQL Server数据库。
I have a table with timestamp column (RowId
) in my SQL Server database.
我想按照这个时间戳来查询新行。 SQL查询以下
I want to query new rows according to this timestamp. The SQL query is following
SELECT *
FROM [MyTable]
where RowId>=0x0000000000A99B06
0x0000000000A99B06
从previous查询的最大时间戳值。
0x0000000000A99B06
is a max timestamp value from the previous query.
我怎么能做出这样的使用实体框架数据库第一查询? 的RowId
映射到字节[]
财产,我不知道如何在LINQ查询比较字节数组。
How can I make such a query using Entity Framework database-first? RowId
maps to byte[]
property and I have no idea how to compare byte arrays in a LINQ query.
您不能与实体框架做到这一点,因为它不允许> =
运营商时间戳比较。它仅允许 =
。你可以做例如。
You can't do this with Entity Framework because it does not allow the >=
operator in timestamp comparisons. It only allows =
. You can do e.g.
var b = BitConverter.GetBytes(1000000L);
var query = from x in MyTable
where x.RowId = b; // not >=
不过,这不会是非常有用的。所以,你一定要找到另一种方式来获得新的行,如在标识列值,或者添加一个真实的时间戳(日期时间)列。
But that would not be very useful. So you've got to find another way to get new rows, e.g. values in an identity column, or add a "real" time stamp (datetime) column.