关系型数据库,基表Guid 主键设值
在我们开发过程,为了自动适应新增修改,可以对基表,Guid 类型进行如下设置:
public bool IsTransient()
{
return this.Id == Guid.Empty;
}
public void GenerateNewIdentity()
{
if (IsTransient())
this.Id = Guid.NewGuid();
}