How to add an computed column to the model class.
I have two models in view,
UserCity
User is connected to City with the CityID (FK contraint) and CityName is in the City model
I wanted the computed column in User model because the .rdlc report does not seems to get value from the City model which is connected to User (in dbml).
Currently when I add the new property to the model then it gives error when the linq query using that model executes.
Invalid column name ‘UserCityName’
which means it tries to select CityName from User from database.
Thanks.
LinqToSQL generate entity as partial class, so you can add additional column to your entity by add new class and add following code.
Example:
Update:
Model.dbmlin your solution window, you will findModel.dbml.layoutandModel.designer.cs.Model.designer.cs, it contains auto-generated class from your databasepublic partial class User. Now you can see, auto-generated class is partial class which mean you can define your class in separate file. Read more