在返回结构中使用带有Enum的Tuple表示法时,得到“对象引用未设置为对象的实例”。
如果我将元组中的类型从Enum类型更改为字符串,则它应按预期工作,如果我将其更改为仅返回一个值(字符串或枚举),则它应按预期工作。
这是ServiceStack中的错误吗? 我正在LinqPad v5.31.0中运行ServiceStack.OrmLite.SqlServer v5.4.0
void Main()
{
var uniqueId = "a635266024448923446";
var result = new Dictionary<Language, string>();
using (var db = _connectionFactory.OpenDbConnection())
{
// This works fine
var rows1 = db.Select<A>("select LanguageId, Name from tblTable");
foreach (var row in rows1)
{
result.Add(row.LanguageId, row.Name);
}
}
using (var db = _connectionFactory.OpenDbConnection())
{
// This throws "Object reference not set to an instance of an object."
var rows2 = db.Select<(Language Language, string Name)>("select LanguageId, Name from tblTable");
foreach (var row in rows2)
{
result.Add(row.Language, row.Name);
}
}
}
public class A
{
public Language LanguageId { get; set; }
public string Name { get; set; }
}
public enum Language
{
NO,
EN,
SV,
DK
}