Exemplo n.º 1
0
        /// <summary>
        ///	根据对象的主键获取唯一对象
        /// 注意,这个方法必须与只能通过主键来获取,因为只有主键在逻辑能确定唯一
        /// 支持双主键,如果是双主键,则两个主键属性必须都要赋上
        /// 如果不能通过主键唯一确定的,则可以通过RetrieveCriteria对象来获取。
        /// 这个方法采用With(nolock)的方式,此方法只针对SQL Server与Access有效
        /// 此方法暂时已经注销。全部的所有的查询都加上了With(nolock)了。
        /// <param name="WithNoLock">采用 with(nolock)方式</param>
        /// <returns></returns>
        //public bool Retrieve(bool WithNoLock)
        //{
        //    PersistenceBroker broker = PersistenceBroker.Instance();
        //    this._IsSaveInMemory = broker.GetClassMap(thisType.Name).IsSaveToMemory;
        //    return broker.RetrieveObject(this, true,WithNoLock);
        //}

        /// <summary>
        ///		获取对象 可选择是否连同于其关联的对象一起获取
        /// </summary>
        /// <returns></returns>
//		public bool Retrieve(bool isRetrieveAssociation)
//		{
//			PersistenceBroker broker=PersistenceBroker.Instance();
//			this._IsSaveInMemory =broker.GetClassMap(thisType.Name).IsSaveToMemory;
//			return broker.RetrieveObject(this,isRetrieveAssociation);
//		}
        /// <summary>
        ///		删除
        /// </summary>
        public int Delete()
        {
            PersistenceBroker broker = PersistenceBroker.Instance();

            this._IsSaveInMemory = broker.GetClassMap(thisType.Name).IsSaveToMemory;
            return(broker.DeleteObject(this));
        }