What you're doing is filtering on a field in the entities. So if you have a set of orders and you want to filter the view on only orders from customer "ALFKI" then you use a predicate like you do:
viewCollection.Filter = (OrderFields.CustomerId="ALFKI")
however you want to filter on a property of a value in an entity, so you have to do something else.
You have to use a DelegatePredicate<T>. Example:
[Test]
public void EntityViewFilteredOnDelegate()
{
using(var adapter = new DataAccessAdapter())
{
var customers = new NWHC.EntityCollection<CustomerEntity>();
adapter.FetchEntityCollection(customers, null);
Assert.AreEqual(91, customers.Count);
var view = new EntityView2<CustomerEntity>(customers);
Assert.AreEqual(91, view.Count);
view.Filter = new DelegatePredicate<CustomerEntity>(e => e.CompanyName.Length > 15);
Assert.AreEqual(64, view.Count);
foreach(var c in view)
{
Assert.IsTrue(c.CompanyName.Length > 15);
}
}
}
So it takes a lambda. In VB, this then becomes for you:
viewCollection.Filter = New DelegatePredicate(Of AEntity)(Function(e) e.FieldName.Length > 5)
Where FieldName is the field you want to filter on.
I had previously used a DbFunctionCall for "LENGTH" when creating expressions for pulling the data into an entity collection. I didn't think it would work in this context - filtering an entity collection to create an entity view.
If this didn't work, perhaps you specified the function call wrong? You can see the query being generated by enabling tracing, see 'Troubleshooting and Debugging' in the runtime manual.