views:

20

answers:

1

Let's say I have a Person table with a FirstName and LastName column. I extended the Person LINQ entity class with a get property "FullName", that concatenates the first and last names.

A LINQ query like: from person... select fullName where id = x
generates SQL selecting all Patient columns, since FullName is evaluated after firing the query. I would like to limit the select clause to only the 2 columns required.

This is a simple example, but the limitation it shows is that I cannot isolate my business/formatting rules but have to embed them in the LINQ query, so they're not reusable (since it is in the select part) or I need select both columns separately, and then concatenate them higher up in the data or business layer with static helper methods.

Any ideas for a clean design using the entity partial classes or extensions?

Thanks

A: 

Personally, I'd create a computed column at the table level so it's part of the entity you store in a row

gbn