You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using Common.Snowflake ;
using System.ComponentModel ;
namespace Common.Core
{
/// <summary>
/// 数据库Id为numberic类型的数据实体使用该基类, 用法同Entity
/// 数据库Id字段为numberic(16,0)或以上长度的整型, 采用雪花算法生成Id。
/// </summary>
public class LongEntity : BaseEntity
{
[Browsable(false)]
public decimal Id { get ; set ; }
public override bool KeyIsNull ( )
{
return Id = = 0 ;
}
static LongEntity ( )
{
//设置参数,程序初始化时执行一次
var options = new IdGeneratorOptions ( )
{
Method = 1 ,
WorkerId = 1
} ;
YitIdHelper . SetIdGenerator ( options ) ;
}
/// <summary>
/// 采用雪花算法计算Id
/// </summary>
public override void GenerateDefaultKeyVal ( )
{
Id = YitIdHelper . NextId ( ) ;
}
}
}