I'm looking for the best way to handle columns which are calculated on the database (not at the client). The reason for that is performance.
For example this is an invoicing program, and next to each customer I want to display a current balance (all invoice amounts minus all payment amounts). I can think of 3 ways to accomplish this:
1) adding a property to the Customer class which calculates the balance on the client side. This is obviously not efficient; this is what I currently do.
2) Can I use entity sql to calculate it at the db? i don't know entity sql at all so before i go learning I want to know if it's even possible / practical for this.
3) create a view on the database and map to that instead of the table
Am I missing something better? Which is best?
Thanks! -Carl
[edit] For what it's worth, option #3 seems the most practical to me. I created the view but now I encounter a problem when associating it to the original table - the problem is described here: http://stackoverflow.com/questions/3336185/entities-framework-mapping-association-between-view-and-table