I found this question's accepted answer very informative to use Expressions with Linq to Entities. I can't figure out the VB.NET syntax, however.
Given something like (this part being in C# is fine)
public class MyCSClass
{
public static Expression<Func<unit, bool>> IsSomeStatus()
{
return u => u.IDStatus == (int)Enums.UnitStatus.SomeStatus;
}
}
How do I put this expression in VB.NET like I would in C# like:
db.units.Any(MyCSClass.IsSomeStatus());
VB.NET doesn't recognize the type when I do either:
db.units.Where(MyCSClass.IsSomeStatus())
(Value of type 'Expression(Of Func(Of unit, Boolean))' cannot be converted to 'Func(Of unit, Boolean)')
or
db.units.Where(Function(u) MyCSClass.IsSomeStatus())
(Value of type 'Expression(Of Func(Of unit, Boolean))' cannot be converted to 'Boolean')