Why does LINQ-to-Entites recognize my custom method?
Posted
by BlueRaja The Green Unicorn
on Stack Overflow
See other posts from Stack Overflow
or by BlueRaja The Green Unicorn
Published on 2010-04-20T13:42:55Z
Indexed on
2010/04/20
14:13 UTC
Read the original article
Hit count: 287
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);
}
© Stack Overflow or respective owner