Is it possible to query using Linq?
When I first tried
dynamic dynamicYaml = new DynamicYaml(MappingYaml);
var x = (decimal)dynamicYaml.items.First().price;
it complained that First() was not a method of DynamicYaml. So I added it, and it worked:
public DynamicYaml First()
{
return Children.First();
}
Then I added
public DynamicYaml First(Func<DynamicYaml,bool> predicate)
{
if (predicate == null) throw new ArgumentNullException("predicate");
return Children.First(predicate);
}
But if I try
var x = (decimal)dynamicYaml.items.First(x => ((string)x.receipt).Contains("OZ")).price;
the compiler complains :
"Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"
Is it possible to query using Linq?
When I first tried
dynamic dynamicYaml = new DynamicYaml(MappingYaml);
var x = (decimal)dynamicYaml.items.First().price;
it complained that First() was not a method of DynamicYaml. So I added it, and it worked:
public DynamicYaml First()
{
return Children.First();
}
Then I added
public DynamicYaml First(Func<DynamicYaml,bool> predicate)
{
if (predicate == null) throw new ArgumentNullException("predicate");
return Children.First(predicate);
}
But if I try
var x = (decimal)dynamicYaml.items.First(x => ((string)x.receipt).Contains("OZ")).price;
the compiler complains :
"Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"