Answers for "mongodb custom IIdGenerator"

C#
0

mongodb custom IIdGenerator

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);
	}
}
Posted by: Guest on March-27-2020

C# Answers by Framework

Browse Popular Code Answers by Language