我需要从我的数据库中获取billers列表.这是我的代码:
public static List<dynamic> GetBillers()
{
DataLayer.DLContext context = new DataLayer.DLContext();
var Billers = (from b in context.Biller
where b.IsActive == true && b.IsDeleted == false
select new
{
ID = b.ID,
DisplayName = b.DisplayName
}).ToList();
return Billers;
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
无法隐式转换
Collections.Generic.List<AnonymousType#1>为System.Collections.Generic.List<dynamic>
请帮忙.
(from b in context.Biller
where b.IsActive == true && b.IsDeleted == false
select (dynamic) new {
ID = b.ID,
DisplayName = b.DisplayName
}).ToList();
Run Code Online (Sandbox Code Playgroud)
应该做的工作.但就个人而言,我不确定这是一个特别有用的举动 - 我建议返回一个已知的类/接口.dynamic有各种用途,但这不是一个好的.