C# 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List”
但我收到一个错误报告,C无法转换列表: 错误:无法隐式转换类型C# 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List”,c#,linq,C#,Linq,但我收到一个错误报告,C无法转换列表: 错误:无法隐式转换类型 请用适当的解决方案指导我如何完成这一点,谢谢…以下几行创建了一个新的匿名对象,其中包含一个日期时间属性: 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<System.DateTime>' 尝试此操作以获取日期时间列表: select
请用适当的解决方案指导我如何完成这一点,谢谢…以下几行创建了一个新的匿名对象,其中包含一个日期时间属性:
'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<System.DateTime>'
尝试此操作以获取日期时间列表:
select new
{
Read_DATE = ((from mstdoc in mstdocs
where
mstdoc.docid == a.docid &&
mstdoc.vtype == "read"
select new
{
mstdoc.DCREA
}).First().DCREA)
}
首先,你不能在同一个方法中定义两个同名的变量,比如List listdate和var listdate。你必须两次定义同一个变量,我是说listdate好的,我了解了变量:事实上嵌套的匿名对象也是多余的,可以删除,
select new
{
Read_DATE = ((from mstdoc in mstdocs
where
mstdoc.docid == a.docid &&
mstdoc.vtype == "read"
select new
{
mstdoc.DCREA
}).First().DCREA)
}
select ((from mstdoc in mstdocs
where
mstdoc.docid == a.docid &&
mstdoc.vtype == "read"
select new
{
mstdoc.DCREA
}).First().DCREA)