Cannot implicitly convert type 'System.Collections.Gener

本文关键字:System Collections Gener implicitly convert type Cannot | 更新日期: 2023-09-27 18:03:28

List<DateTime> listdate = new List<DateTime>();
 var InList = (from b in mstdocstats
                            join a in mstdocs on a.docid = b.docid
                            where a.vtype = 'table'
                            && a.DCREA.Month == "06" && a.DCREA.Year == "2016"
                            select a.docid).ToList();

 var listreaddate = (from b in mstdocstats
                    join a in mstdocs on a.docid = b.docid
                    where InList.Contains(a.docid) && a.vtaid = '2'
              && a.vtype = 'read'
                             select new
                              {
                                   Read_DATE = ((from mstdoc in mstdocs
                                                   where
                                                   mstdoc.docid == a.docid &&
                                                     mstdoc.vtype == "read"
                                                   select new
                                                   {
                                                        mstdoc.DCREA
                                                  }).First().DCREA)
                                }).ToList();

但是我得到一个错误报告,c#不能转换列表:

"错误:无法隐式转换类型

'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<System.DateTime>'

请指导我正确的解决方案,我如何才能做到这一点,谢谢…

Cannot implicitly convert type 'System.Collections.Gener

下面的代码创建了一个新的匿名对象,该对象包含一个日期时间属性:

                         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)
相关文章: