public List<Tuple<int, int, int, string, int, int, Tuple<bool, bool, int?>>>
GetValues(int someId, int someOtherlId)
{
var t = new List<Tuple<int, int, int, string, int, int, Tuple<bool, bool, int?>>>();
using (var context = new Entities(ConnString))
{
var pc = context.SomeTable.Where(c => c.SomeId == someId &&
c.SomeOtherId == someOtherId).OrderBy(c => c.Id).ToList();
t.AddRange(pc.Select(cols => new Tuple<int, int, int, string, int, int, Tuple<bool, bool, int?>>
(cols.Id, cols.someId, cols.someOtherId, cols.ColumnName, cols.MinDataLength,
cols.MaxDataLength, new Tuple<bool, bool, int?>(cols.Required, cols.Eav.HasValue && cols.Eav.Value,
cols.AttribId.HasValue ? cols.AttribId.Value : null))));
}
return t;
}
}
无法弄清楚为什么此代码无法编译并生成“'int' 和 'null' 之间没有隐式转换”错误。
在那第二个元组中,int?始终将其标记为可为空,所以为什么它被编译器检测为正常的 int,t.AddRange
其中在cols.AttribId.HasValue ? cols.AttribId.Value : null
.
有任何想法吗?