
Security News
Knip Hits 500 Releases with v5.62.0, Improving TypeScript Config Detection and Plugin Integrations
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Dapper.CustomTypeHandlers
Advanced tools
Dapper custom type handlers to serialize/deserialize objects to Xml and Json.
Dapper custom type handlers to serialize/deserialize objects to Xml and Json. Can be also used to map GUID to a string.
Use NuGet Package Manager
Install-Package Dapper.CustomTypeHandlers
or .NET CLI
dotnet add package Dapper.CustomTypeHandlers
or just copy into the project file to reference the package
<PackageReference Include="Dapper.CustomTypeHandlers" Version="2.3.0" />
public class Book
{
public long Id { get; set; }
public string Title { get; set; }
public BookDescription Description { get; set; }
}
public class BookDescription : IXmlObjectType
{
public Learn Learn { get; set; }
public string About { get; set; }
public Features Features { get; set; }
}
public class Learn
{
public List<string> Points { get; set; }
}
public class Features
{
public List<string> Points { get; set; }
}
services.RegisterDapperCustomTypeHandlers(typeof(Book).Assembly);
CREATE TABLE [dbo].[Books](
[Id] bigint IDENTITY(1,1) NOT NULL,
[Title] nvarchar(200) NOT NULL,
[Description] xml NULL
CONSTRAINT [PK_Books] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
)
To persist object as a JSON, you can use the nvarchar field (class should implement IJsonObjectType)
CREATE TABLE [dbo].[Books](
[Id] bigint IDENTITY(1,1) NOT NULL,
[Title] nvarchar(200) NOT NULL,
[Description] nvarchar(max) NULL
CONSTRAINT [PK_Books] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
)
public async Task SaveBook(Book book)
{
using (var conn = _connectionFactory.Connection())
{
await conn.ExecuteAsync(_@"INSERT INTO Books (Title, Description) VALUES (@Title, @Description)", book);
}
}
Every commit or pull request is built and tested on the Continuous Integration system.
To test locally:
git clone https://github.com/kubagdynia/Dapper.CustomTypeHandlers.git
dotnet test ./Dapper.CustomTypeHandlers/
List of technologies, frameworks and libraries used for implementation:
This project is licensed under the MIT License.
FAQs
Dapper custom type handlers to serialize/deserialize objects to Xml and Json.
We found that dapper.customtypehandlers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.