예제 #1
0
        /// <summary>
        /// 判断对象是否在数据库中存在
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns></returns>
        public bool CheckObj(IDataAccessBase obj)
        {
            CClassQuery ccq = obj.CheckObj();

            if (ccq == null)
            {
                return(false);
            }
            return(HasRecord(ccq.sql, ccq.parameters));
        }
예제 #2
0
        public CDataAccessBase getObj(IDataAccessBase obj)
        {
            CClassQuery ccq = obj.CheckObj();

            if (ccq == null)
            {
                return(null);
            }
            Type t = obj.GetType();

            DataTable       dt = this.ExecQuery(ccq.sql, ccq.parameters);
            CDataAccessBase ba = null;

            int i = 0;

            foreach (DataRow dr in dt.Rows)
            {
                CDataAccessBase k = (CDataAccessBase)Activator.CreateInstance(t);
                k.InitFromDataRow(dr);
                ba = k;
                break;
            }
            return(ba);
        }