Created
April 4, 2024 20:50
-
-
Save madmonkey/9549654c7d243badaacdb68e1e6c9156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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