如何使用DataInfo对象将字符串列表分配给列表。下面我发送我目前的实施和错误。
public class DataInfo
{
public string Data { get; set; }
public DataInfo()
{
this.Data = Data;
}
}
//Controller
List<datainfo> DataList = new List<datainfo>();
DataList = db.Order.OrderBy (w => w.IdOrder) .ToList ();
viewModel.ListPeriods = listOrdersUsers.OrderBy (p => p.AcceptanceDateOrder
). Select (w => w.AcceptanceDateOrder.ToString (). Substring (0, 7)) ToList ();
//错误
//无法隐式转换类型&#39; System.Collections.Generic.List&#39;到&#39; System.Collections.Generic.List
答案 0 :(得分:0)
这是答案
List<DataInfo> DataList = new List<DataInfo>();
DataList = listOrdersUsers.OrderBy<pre>(p => p.AcceptanceDateOrder
). Select (w => new DataInfo{Data = w.AcceptanceDateOrder.ToString().Substring(0, 7)}) ToList();