开发者

IronPython and Entity Framework

Possibly really simple question, but I'm new to IronPython. I would like use IronPython to crawl an entity I pass to it, but when I try to use an开发者_JAVA技巧y extension methods, it, as sort of expected, blows up. How do I traverse my POCOs in IronPython?

delegate bool EvaluateRule(MyEntity entity);
//Keep in mind this is just to test, no actual value provided
string expression = @"entity.Flags.FirstOrDefault() == null";
MyEntity entity = new MyEntity();
PythonEngine engine = new PythonEngine();
EvaluateRule rule = engine.CreateLambda<EvaluateRule>(expression);
bool result = rule.Invoke(entity);

I get the following: 'EntityCollection[MyEntity]' object has no attribute 'FirstOrDefault'

Thanks in advance!


You can call the extension methods as regular static methods:

string expression = @"Enumerable.FirstOrDefault(entity.Flags) == null";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜