如何检查它是否是第一次记录

时间:2013-02-28 09:14:33

标签: c# .net

我正在开发一个应用程序,但是卡在一段代码中,我不知道如何弄清楚,当我从数据库加载数据时,我希望每个记录状态都设置为无。

但未能实现这一目标。这是我的代码。

 
    [Table(`PROGRAM_OFFER`)]
    public class ProgramOffer : DomainObject
    {
        #region -   [   Properties  ]   -

        private decimal _ProgramOfferId { get; set; }
        [PrimaryKey(`PROGRAM_OFFER_ID`)]
        public virtual decimal ProgramOfferId
        {
            get { return _ProgramOfferId; }
            set
            {
                if (_ProgramOfferId != value)
                {
                    _ProgramOfferId = value;
                    NotifyChanged(`ProgramOfferId`);

                    CheckIfFirstRecord();
                }
            }
        }
        private decimal _ProgramId { get; set; }
        [Column(`PROGRAM_ID`)]
        public virtual decimal ProgramId
        {
            get { return _ProgramId; }
            set
            {
                if (_ProgramId != value)
                {
                    _ProgramId = value;
                    NotifyChanged(`ProgramId`);

                    CheckIfFirstRecord();
                }
            }
        }
        private RecordStatus _CurruntRecordStatus { get; set; }
        public RecordStatus CurruntRecordStatus
        {
            get { return _CurruntRecordStatus; }
            set
            {
                if (_CurruntRecordStatus != value)
                    if (value == RecordStatus.None || _CurruntRecordStatus == RecordStatus.None || _CurruntRecordStatus == 0)
                    {
                        _CurruntRecordStatus = value;
                        NotifyChanged("CurruntRecordStatus");
                    }
            }
        }

        private void CheckIfFirstRecord()
        {
            if (ProgramOfferId > 0 && ProgramId > 0 && TermId > 0 && SemesterId > 0)
                if (CurruntRecordStatus == 0)
                    CurruntRecordStatus = RecordStatus.None;
                else
                    CurruntRecordStatus = RecordStatus.Updated;
        }
 

这是我的代码,如果这是第一次加载,如何将CurrentRecordStatus设置为无,

由于

此致

1 个答案:

答案 0 :(得分:0)

如何在构造函数中设置默认值?

public ProgramOffer()
{
    _CurruntRecordStatus = RecordStatus.None;
}