【发布时间】:2017-05-14 08:25:10
【问题描述】:
我的代码应该检查两个条件并返回值,但是当我尝试返回 q 时出现此错误
无法将类型'System.Collections.Generic.List>'隐式转换为'System.Collections.Generic.List
我尝试了所有方法但没有任何效果也不知道设置List<string> 或设置为List<EF_Model.PDF>,PDF 是我模型中的 DTO
这是我的代码
internal List<string> Customers_File(int _id)
{
using (var Context = new EF_Model.CoolerEntities())
{
var q = from c in Context.Customers
where c.Id == _id &&
c.Ref_PDF != null
select new { c.PDF.Name, c.PDF.File };
return q.ToList();
}
}
【问题讨论】:
-
错误信息的哪一部分告诉你到底出了什么问题你不明白?
-
你可以使用:select new string[] { c.PDF.Name, c.PDF.File };
-
那么您希望实际上从您的方法返回什么 - 字符串列表或 PDF 名称和文件列表?
-
我可以看到您拥有哪些字段,并且我知道您希望它“正常工作” - 但不清楚您想做什么!
-
我想从 DB @Jamiec 获取这两个值