/// <summary>
///
/// </summary>
public static class DataBaseGenerator
{
/// <summary>
///
/// </summary>
private static Int64 seed = Int64.Parse(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString("0"));
/// <summary>
///
/// </summary>
/// <returns></returns>
public static Int64 GetPrimaryKey()
{
return Interlocked.Increment(ref seed);
}
}
///
/// </summary>
public static class DataBaseGenerator
{
/// <summary>
///
/// </summary>
private static Int64 seed = Int64.Parse(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString("0"));
/// <summary>
///
/// </summary>
/// <returns></returns>
public static Int64 GetPrimaryKey()
{
return Interlocked.Increment(ref seed);
}
}
最近要使用到流水号功能,网上现有生成ID(流水号)的实现大部分都是使用的存储过程,在我这个项目里面不方便操作。于是自己捣鼓了一下下,欢迎拍砖。