views:

17

answers:

2

hey, there, is there any way to ass a NON DB property to a Linq-to-SQL class? (etc calculated fields), I'm getting an error when trying

+1  A: 

duplicate :

http://stackoverflow.com/questions/587836/linq-add-property-to-results

seems there are a couple methods available.

Orbit
+2  A: 

Linq2Sql generates your entities as partial classes. This makes it easy to extend these classes yourself without modifying the code generated by L2S (which is a bad idea since it will be overwritten if you update your model and regenerate.)

Just find the partial class definition and create a new source file where you declare the same partial class. Inside that new class, add the property or methods that you want to use in your code but Linq2Sql will not have any knowledge of.

Erik Noren