문제

I have table CustomerPurchase and equivalent data class DBML file also created. In this, DBML class, I have added my Custom field 'TotalAmount' for calculations to show in the Listivew. but InsertOnSubmit(), it is throwing an error as Invalid column name 'TotalAmount'.

How can I exclude this user defined field while submit?

도움이 되었습니까?

해결책

If you look inside the dbml file, you can see it is generate partial classes, so you can some partial classes to your entities, and create other properties, like TotalAmount you need. There you can access other properties and make calculated property, for sample:

namespace YourEntityNameSpace
{
    public partial class CustomerPurchase 
    {
        public double TotalAmount
        { 
            get
            {
                // your code goes here to calculate, for sample:
                return UnitPrice * Amount;
            }
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top