关系型数据库,基表Guid 主键设值

 

在我们开发过程,为了自动适应新增修改,可以对基表,Guid 类型进行如下设置:

public bool IsTransient()
{
       return this.Id == Guid.Empty;
}

public void GenerateNewIdentity()
{
       if (IsTransient())
       this.Id = Guid.NewGuid();
}

posted @ 2019-12-25 17:07  蜗牛行  阅读(214)  评论(0编辑  收藏  举报