Commit bd515678 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

sqlite: Handle enum with duplicated values

Fix #139
parent 95df673b
......@@ -2030,7 +2030,19 @@ namespace SQLite
{
// This is a big assumption, but for now support ints only as key, otherwise we still
// have to pay the price for boxing
EnumValues = Enum.GetValues(type).Cast<int>().ToDictionary(x => x, x => x.ToString());
var values = Enum.GetValues(type).Cast<int>();
EnumValues = new Dictionary<int, string>();
foreach (var v in values)
{
try
{
EnumValues.Add(v, v.ToString());
}
catch (ArgumentException)
{
// Ignore duplicated element.
}
}
#if !USE_NEW_REFLECTION_API
StoreAsText = type.GetCustomAttribute(typeof(StoreAsTextAttribute), false) != null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment