Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
	}
}
 
PREVIOUS NEXT
Tagged: #mongodb #custom #IIdGenerator
ADD COMMENT
Topic
Name
7+5 =