Skip to content

Instantly share code, notes, and snippets.

@madmonkey
Created April 4, 2024 20:50
Show Gist options
  • Save madmonkey/9549654c7d243badaacdb68e1e6c9156 to your computer and use it in GitHub Desktop.
Save madmonkey/9549654c7d243badaacdb68e1e6c9156 to your computer and use it in GitHub Desktop.
public class GenericTypeHandler<T> : SqlMapper.TypeHandler<T>
{
public override T Parse(object value)
{
return JsonConvert.DeserializeObject<T>(value.ToString());
}
public override void SetValue(IDbDataParameter parameter, T value)
{
parameter.Value = JsonConvert.SerializeObject(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment