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";
精彩评论