Provides Dapper type handlers for the UUID library, enabling seamless integration with database operations. Features include binary and string storage options, thread-safe implementation, comprehensive error handling, and efficient database type mapping. Optimized for both performance and flexibility across different .NET platforms and database systems.
$ dotnet add package UUID.Serialization.DapperA Dapper type handler provider for the UUID library.
dotnet add package UUID.Serialization.Dapper
using Dapper;
// Register the binary handler (recommended for storage efficiency)
SqlMapper.AddTypeHandler(new BinaryUUIDHandler());
// Or register the string handler (if you need human-readable values)
SqlMapper.AddTypeHandler(new StringUUIDHandler());
// Or register the Base64 handler (for compact string representation)
SqlMapper.AddTypeHandler(new Base64UUIDHandler());
// Example query
var user = connection.QuerySingle<User>("SELECT * FROM Users WHERE Id = @Id", new { Id = UUID.New() });
public class UserModel
{
public UUID Id { get; set; }
public string Name { get; set; }
}
// Example insert
var user = new UserModel
{
Id = UUID.New(),
Name = "John Doe"
};
connection.Execute("INSERT INTO Users (Id, Name) VALUES (@Id, @Name)", user);
// Example select
var users = connection.Query<UserModel>("SELECT * FROM Users");
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms of the LICENSE file included in the root directory.