📜  mongodb 自定义 IIdGenerator - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:59.488000             🧑  作者: Mango

代码示例1
public class GuidIdGenerator : IIdGenerator
{
    public object GenerateId(object container, object document)
    {
        return Guid.NewGuid().ToString();
    }

    public bool IsEmpty(object id)
    {
        return !(id is string guid) || string.IsNullOrEmpty(guid);
    }
}