Why does LINQ-to-Entites recognize my custom method?
- by BlueRaja The Green Unicorn
This works:
(from o in Entities.WorkOrderSet
select o)
.Where(MyCustomMethod);
This does not:
(from o in Entities.WorkOrderSet
select new { WorkOrder = o })
.Where(o => MyCustomMethod(o.WorkOrder);
I understand why the second doesn't work - but why in the world does the first work!? Shouldn't I get a "custom method not recognized?"
For reference, here is MyCustomMethod
public bool MyCustomMethod(WorkOrder workOrder)
{
return !workOrder.WorkOrderNum.StartsWith("A", StringComparison.CurrentCultureIgnoreCase);
}