相关疑难解决方法(0)

C#字节数组比较

我使用.NET 3.0在C#中有两个字节数组.

比较两个字节数组是否包含每个元素的相同内容的"最有效"方法是什么?

例如,字节数组{0x1, 0x2}{0x1, 0x2}.但字节数组{0x1, 0x2}和字节数组{0x2, 0x1}不一样.

.net c# bytearray

14
推荐指数
3
解决办法
2万
查看次数

查询从LINQ到SQL的时间戳列

我的表有一个名为"RowVer"的时间戳列,LINQ映射到System.Data.Linq.Binary类型.这种数据类型对我来说似乎没用,因为(除非我遗漏了什么)我不能做这样的事情:

// Select all records that changed since the last time we inserted/updated.
IEnumerable<UserSession> rows = db.UserSessions.Where
( usr => usr.RowVer > ???? );
Run Code Online (Sandbox Code Playgroud)

所以,我正在寻找的解决方案之一是添加一个名为RowTrack的新"计算列",它在SQL中定义如下:

CREATE TABLE UserSession
(
RowVer timestamp NOT NULL,
RowTrack  AS (convert(bigint,[RowVer])),
-- ... other columns ...
)
Run Code Online (Sandbox Code Playgroud)

这允许我像我想要的那样查询数据库:

// Select all records that changed since the last time we inserted/updated.
IEnumerable<UserSession> rows = db.UserSessions.Where
( usr => usr.RowTrack > 123456 );
Run Code Online (Sandbox Code Playgroud)

这是一个糟糕的做事方式吗?查询计算列的性能如何?有更好的解决方法吗?

此外,我正在开发针对Sql Server 2000的最终向后兼容性,但我可以与老板谈论使2005年成为最低的共同点.

linq sql-server performance

7
推荐指数
3
解决办法
4701
查看次数

标签 统计

.net ×1

bytearray ×1

c# ×1

linq ×1

performance ×1

sql-server ×1