我正在尝试从存储过程的结果转换为 List .. 我已经为timerangeResult -> Booking的单个对象创建了显式(工作)转换,但是我缺少一个列表..
这是代码:
public static explicit operator List<Booking>(timerangeResult t)
{
List<Booking> bL = new List<Booking>();
IEnumerable<timerangeResult> tx = (IEnumerable<timerangeResult>) t;
foreach (timerangeResult tt in tx)
{
Booking b = (Booking)tt;
bL.Add(b);
}
//return bL;
//return new List<Booking>(bL);
//return new List<Booking>(IEnumerable < Booking > bL);
return bL;
// [NONE OF THESE WORK]
// ERROR:
// User-defined conversion must convert to or from the enclosing type (UNDERLINED: "explicit operator List<Booking>" line 1)
}
提前致谢!