栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

顺序引导发生器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

顺序引导发生器

这个人想出了一些顺序建议,这是一个链接

http://developmenttips.blogspot.com/2008/03/generate-sequential-guids-for-
sql.html

相关代码:

public class SequentialGuid {    Guid _CurrentGuid;    public Guid CurrentGuid {        get { return _CurrentGuid;        }    }    public SequentialGuid() {        _CurrentGuid = Guid.NewGuid();    }    public SequentialGuid(Guid previousGuid) {        _CurrentGuid = previousGuid;    }    public static SequentialGuid operator++(SequentialGuid sequentialGuid) {        byte[] bytes = sequentialGuid._CurrentGuid.ToByteArray();        for (int mapIndex = 0; mapIndex < 16; mapIndex++) { int bytesIndex = SqlOrderMap[mapIndex]; bytes[bytesIndex]++; if (bytes[bytesIndex] != 0) {     break; // No need to increment more significant bytes }        }        sequentialGuid._CurrentGuid = new Guid(bytes);        return sequentialGuid;    }    private static int[] _SqlOrderMap = null;    private static int[] SqlOrderMap {        get { if (_SqlOrderMap == null) {     _SqlOrderMap = new int[16] {         3, 2, 1, 0, 5, 4, 7, 6, 9, 8, 15, 14, 13, 12, 11, 10     };     // 3 - the least significant byte in Guid ByteArray [for SQL Server ORDER BY clause]     // 10 - the most significant byte in Guid ByteArray [for SQL Server ORDERY BY clause] } return _SqlOrderMap;        }    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/394091.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号