示例#1
0
        //数据持久化
        internal static void  SaveToDb(EducationInfo pEducationInfo, Education pEducation, bool pIsNew)
        {
            pEducation.EducationId   = pEducationInfo.educationId;
            pEducation.EducationName = pEducationInfo.educationName;
            pEducation.IsNew         = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pEducation.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(EducationInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pEducationInfo.educationId = pEducation.EducationId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)))
            {
                ResetCache();
            }
        }
示例#2
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <EducationInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <EducationInfo> list = new List <EducationInfo>();

            Query q = Education.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            EducationCollection collection = new  EducationCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Education education  in collection)
            {
                EducationInfo educationInfo = new EducationInfo();
                LoadFromDAL(educationInfo, education);
                list.Add(educationInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
示例#3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <EducationInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <EducationInfo>);
            }
            else
            {
                List <EducationInfo> list       = new List <EducationInfo>();
                EducationCollection  collection = new  EducationCollection();
                Query qry = new Query(Education.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Education education in collection)
                {
                    EducationInfo educationInfo = new EducationInfo();
                    LoadFromDAL(educationInfo, education);
                    list.Add(educationInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
示例#4
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <EducationInfo> pList, EducationCollection pCollection)
 {
     foreach (Education education in pCollection)
     {
         EducationInfo educationInfo = new EducationInfo();
         LoadFromDAL(educationInfo, education);
         pList.Add(educationInfo);
     }
 }
        public EducationInfo GetEducationInfoById(int EducationId)
        {
            EducationInfo educationInfo  = null;//
            try
            {
                 educationInfo = new EducationInfo(EducationId);

            }
            catch (AppException)
            {
                return null;
            }

            return  educationInfo;
        }
示例#6
0
        public EducationInfo GetEducationInfoById(int EducationId)
        {
            EducationInfo educationInfo = null;             //

            try
            {
                educationInfo = new EducationInfo(EducationId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(educationInfo);
        }
示例#7
0
 private void LoadFromId(int educationId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)))
     {
         EducationInfo educationInfo = Find(GetList(), educationId);
         if (educationInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(educationInfo, this);
     }
     else
     {
         Education education = new Education(educationId);
         if (education.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, education);
     }
 }
示例#8
0
 //从后台获取数据
 internal static void  LoadFromDAL(EducationInfo pEducationInfo, Education pEducation)
 {
     pEducationInfo.educationId   = pEducation.EducationId;
     pEducationInfo.educationName = pEducation.EducationName;
     pEducationInfo.Loaded        = true;
 }
示例#9
0
 public List <EducationInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(EducationInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
示例#10
0
 //从后台获取数据
 internal static void LoadFromDAL(EducationInfo pEducationInfo, Education  pEducation)
 {
     pEducationInfo.educationId = pEducation.EducationId;
      		pEducationInfo.educationName = pEducation.EducationName;
     pEducationInfo.Loaded=true;
 }
示例#11
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(EducationInfo pEducationInfoTo)
 {
     Copy(this,  pEducationInfoTo);
 }
示例#12
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<EducationInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< EducationInfo> list = new List< EducationInfo>();

            Query q = Education .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            EducationCollection  collection=new  EducationCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Education  education  in collection)
            {
                EducationInfo educationInfo = new EducationInfo();
                LoadFromDAL(educationInfo,   education);
                list.Add(educationInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
示例#13
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<EducationInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< EducationInfo>;
     }
     else
     {
         List< EducationInfo>  list =new List< EducationInfo>();
         EducationCollection  collection=new  EducationCollection();
         Query qry = new Query(Education.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Education education in collection)
         {
             EducationInfo educationInfo= new EducationInfo();
             LoadFromDAL(educationInfo,education);
             list.Add(educationInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
示例#14
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(EducationInfo pEducationInfoFrom, EducationInfo pEducationInfoTo)
 {
     pEducationInfoTo.EducationId = pEducationInfoFrom.educationId;
      		pEducationInfoTo.EducationName = pEducationInfoFrom.educationName;
     pEducationInfoTo.Loaded=pEducationInfoFrom.Loaded;
 }
示例#15
0
 public object SaveEducationInfo(EducationInfo educationInfo)
 {
     educationInfo.Save();
     return educationInfo . EducationId;
 }
示例#16
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(EducationInfo pEducationInfoTo)
 {
     Copy(this, pEducationInfoTo);
 }
示例#17
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< EducationInfo> pList, EducationCollection pCollection)
 {
     foreach (Education education in pCollection)
     {
         EducationInfo educationInfo = new EducationInfo();
         LoadFromDAL(educationInfo, education );
         pList.Add(educationInfo);
     }
 }
示例#18
0
        public void DeleteById(EducationInfo pEducationInfo)
        {
            EducationInfo educationInfo = new EducationInfo(pEducationInfo.EducationId);

            educationInfo.Delete();
        }
示例#19
0
 //数据持久化
 internal static void SaveToDb(EducationInfo pEducationInfo, Education  pEducation,bool pIsNew)
 {
     pEducation.EducationId = pEducationInfo.educationId;
      		pEducation.EducationName = pEducationInfo.educationName;
     pEducation.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pEducation.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(EducationInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pEducationInfo.educationId = pEducation.EducationId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(EducationInfo)))
     {
         ResetCache();
     }
 }
示例#20
0
 public List <EducationInfo> GetEducationInfoList()
 {
     return(EducationInfo.GetList());
 }
示例#21
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(EducationInfo pEducationInfoFrom, EducationInfo pEducationInfoTo)
 {
     pEducationInfoTo.EducationId   = pEducationInfoFrom.educationId;
     pEducationInfoTo.EducationName = pEducationInfoFrom.educationName;
     pEducationInfoTo.Loaded        = pEducationInfoFrom.Loaded;
 }
示例#22
0
 public object  SaveEducationInfo(EducationInfo educationInfo)
 {
     educationInfo.Save();
     return(educationInfo.EducationId);
 }
示例#23
0
 public void DeleteById(EducationInfo pEducationInfo)
 {
     EducationInfo educationInfo = new EducationInfo(pEducationInfo.EducationId);
     educationInfo.Delete();
 }