学习伴随一生
没有绝对,只有相对
    /// <summary>
    
/// 
    
/// </summary>
    public static class DataBaseGenerator
    {
        /// <summary>
        
///
        
/// </summary>
        private static Int64 seed = Int64.Parse(DateTime.UtcNow.Subtract(new DateTime(197011)).TotalMilliseconds.ToString("0"));

        /// <summary>
        
///
        
/// </summary>
        
/// <returns></returns>
        public static Int64 GetPrimaryKey()
        {
            return Interlocked.Increment(ref seed);
        }
    }
最近要使用到流水号功能,网上现有生成ID(流水号)的实现大部分都是使用的存储过程,在我这个项目里面不方便操作。于是自己捣鼓了一下下,欢迎拍砖。
posted on 2011-10-09 12:54  蒋正  阅读(3304)  评论(5编辑  收藏  举报