我想在一个IEnumerable<dynamic>
类型上使用一个 lambda 表达式,但是我在使用新的 lambda 表达式的属性和坐标上得到以下错误:
Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
.
这是我的代码
public static object returnFullSelectWithCoordinates(IEnumerable<dynamic> q)
{
return q.Select(b => new
{
route_id = b.b.route_id,
name = b.b.name,
description = b.b.description,
attributes = b.b.route_attributes.Select(c => c.route_attribute_types.attribute_name),
coordinates = b.b.coordinates.Select(c => new coordinateToSend { sequence = c.sequence, lat = c.position.Latitude, lon = c.position.Longitude })
});
有什么解决方法可以使我的方法有效吗?