Search code examples
c#linqvisual-studio-lightswitchcomputed-properties

Linq to SQL query filter with Lightswitch computed property


With the help/suggestions I received in a previous question I asked, I managed to narrow my problem down to a computed property.

Here's the query filtering that fails:

query = query.Where(a => a.collection.Any(b => b.Name.StartsWith(c)));

Everything in there seems to work fine but Name causes the query to fail. Name is a computed property of b and when I replace that by a standard property, the query works.

I do not understand what that implies in the sql so I can't figure out how to fix/replace that so I can filter by that property. If anyone could explain what's going wrong behind that query it'd be appreciated.


Solution

  • Computed properties are not defined in the underlying database and so you can't reference them in your queries.