There’s a cool little function in STD’s called the expression, you can use it to do math etc on a column without getting the database to return it. Thus making life easier on the DB.

In one of my webservices Im writing there is a monster of a Set part of this set contains the Languages Spoken by a person and a table of languages.

Now rather than the client having to do a lookup themselves for the language description I was doing a join in the DB and returning the Description from the Languages table. Now Fact is I’m already returning all the languages in a table with a relation on it so what a waste of a join I thought. Why cant I calculate the Parent rows description in the expression field I have the key after all.

Well you can, in the expression you can do something like:-

Parent(RelationNameWithoutQuotesAndInBrackets).Description

(See page 320 in ADO.NET Book)

Advertisements