using Dapper;
|
using System;
|
using System.Data;
|
|
namespace WIDESEA_Core.Dapper
|
{
|
public class DapperParseGuidTypeHandler : SqlMapper.TypeHandler<Guid?>
|
{
|
public override void SetValue(IDbDataParameter parameter, Guid? guid)
|
{
|
parameter.Value = guid.ToString();
|
}
|
|
public override Guid? Parse(object value)
|
{
|
if (value == null || value.ToString() == "")
|
{
|
return null;
|
}
|
if (value.GetType() == typeof(string))
|
{
|
return new Guid((string)value);
|
}
|
return (Guid)value;
|
}
|
}
|
}
|