/// <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 <OfferPriceTypeInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <OfferPriceTypeInfo> list = new List <OfferPriceTypeInfo>(); Query q = OfferPriceType.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); OfferPriceTypeCollection collection = new OfferPriceTypeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OfferPriceType offerPriceType in collection) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo, offerPriceType); list.Add(offerPriceTypeInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <OfferPriceTypeInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <OfferPriceTypeInfo>); } else { List <OfferPriceTypeInfo> list = new List <OfferPriceTypeInfo>(); OfferPriceTypeCollection collection = new OfferPriceTypeCollection(); Query qry = new Query(OfferPriceType.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (OfferPriceType offerPriceType in collection) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo, offerPriceType); list.Add(offerPriceTypeInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
//数据持久化 internal static void SaveToDb(OfferPriceTypeInfo pOfferPriceTypeInfo, OfferPriceType pOfferPriceType, bool pIsNew) { pOfferPriceType.OfferPriceTypeId = pOfferPriceTypeInfo.offerPriceTypeId; pOfferPriceType.OfferPriceTypeName = pOfferPriceTypeInfo.offerPriceTypeName; pOfferPriceType.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOfferPriceType.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(OfferPriceTypeInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOfferPriceTypeInfo.offerPriceTypeId = pOfferPriceType.OfferPriceTypeId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo))) { ResetCache(); } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <OfferPriceTypeInfo> pList, OfferPriceTypeCollection pCollection) { foreach (OfferPriceType offerPriceType in pCollection) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo, offerPriceType); pList.Add(offerPriceTypeInfo); } }
public OfferPriceTypeInfo GetOfferPriceTypeInfoById(int OfferPriceTypeId) { OfferPriceTypeInfo offerPriceTypeInfo = null;// try { offerPriceTypeInfo = new OfferPriceTypeInfo(OfferPriceTypeId); } catch (AppException) { return null; } return offerPriceTypeInfo; }
public OfferPriceTypeInfo GetOfferPriceTypeInfoById(int OfferPriceTypeId) { OfferPriceTypeInfo offerPriceTypeInfo = null; // try { offerPriceTypeInfo = new OfferPriceTypeInfo(OfferPriceTypeId); } catch (AppException) { return(null); } return(offerPriceTypeInfo); }
private void LoadFromId(int offerPriceTypeId) { if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo))) { OfferPriceTypeInfo offerPriceTypeInfo = Find(GetList(), offerPriceTypeId); if (offerPriceTypeInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(offerPriceTypeInfo, this); } else { OfferPriceType offerPriceType = new OfferPriceType(offerPriceTypeId); if (offerPriceType.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, offerPriceType); } }
/// <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<OfferPriceTypeInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< OfferPriceTypeInfo> list = new List< OfferPriceTypeInfo>(); Query q = OfferPriceType .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); OfferPriceTypeCollection collection=new OfferPriceTypeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OfferPriceType offerPriceType in collection) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo, offerPriceType); list.Add(offerPriceTypeInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<OfferPriceTypeInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< OfferPriceTypeInfo>; } else { List< OfferPriceTypeInfo> list =new List< OfferPriceTypeInfo>(); OfferPriceTypeCollection collection=new OfferPriceTypeCollection(); Query qry = new Query(OfferPriceType.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(OfferPriceType offerPriceType in collection) { OfferPriceTypeInfo offerPriceTypeInfo= new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo,offerPriceType); list.Add(offerPriceTypeInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OfferPriceTypeInfo pOfferPriceTypeInfoFrom, OfferPriceTypeInfo pOfferPriceTypeInfoTo) { pOfferPriceTypeInfoTo.OfferPriceTypeId = pOfferPriceTypeInfoFrom.offerPriceTypeId; pOfferPriceTypeInfoTo.OfferPriceTypeName = pOfferPriceTypeInfoFrom.offerPriceTypeName; pOfferPriceTypeInfoTo.Loaded=pOfferPriceTypeInfoFrom.Loaded; }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(OfferPriceTypeInfo pOfferPriceTypeInfoTo) { Copy(this, pOfferPriceTypeInfoTo); }
public object SaveOfferPriceTypeInfo(OfferPriceTypeInfo offerPriceTypeInfo) { offerPriceTypeInfo.Save(); return offerPriceTypeInfo . OfferPriceTypeId; }
public void DeleteById(OfferPriceTypeInfo pOfferPriceTypeInfo) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(pOfferPriceTypeInfo.OfferPriceTypeId); offerPriceTypeInfo.Delete(); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< OfferPriceTypeInfo> pList, OfferPriceTypeCollection pCollection) { foreach (OfferPriceType offerPriceType in pCollection) { OfferPriceTypeInfo offerPriceTypeInfo = new OfferPriceTypeInfo(); LoadFromDAL(offerPriceTypeInfo, offerPriceType ); pList.Add(offerPriceTypeInfo); } }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OfferPriceTypeInfo pOfferPriceTypeInfoFrom, OfferPriceTypeInfo pOfferPriceTypeInfoTo) { pOfferPriceTypeInfoTo.OfferPriceTypeId = pOfferPriceTypeInfoFrom.offerPriceTypeId; pOfferPriceTypeInfoTo.OfferPriceTypeName = pOfferPriceTypeInfoFrom.offerPriceTypeName; pOfferPriceTypeInfoTo.Loaded = pOfferPriceTypeInfoFrom.Loaded; }
public object SaveOfferPriceTypeInfo(OfferPriceTypeInfo offerPriceTypeInfo) { offerPriceTypeInfo.Save(); return(offerPriceTypeInfo.OfferPriceTypeId); }
public List <OfferPriceTypeInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(OfferPriceTypeInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
public List <OfferPriceTypeInfo> GetOfferPriceTypeInfoList() { return(OfferPriceTypeInfo.GetList()); }
//从后台获取数据 internal static void LoadFromDAL(OfferPriceTypeInfo pOfferPriceTypeInfo, OfferPriceType pOfferPriceType) { pOfferPriceTypeInfo.offerPriceTypeId = pOfferPriceType.OfferPriceTypeId; pOfferPriceTypeInfo.offerPriceTypeName = pOfferPriceType.OfferPriceTypeName; pOfferPriceTypeInfo.Loaded=true; }
//从后台获取数据 internal static void LoadFromDAL(OfferPriceTypeInfo pOfferPriceTypeInfo, OfferPriceType pOfferPriceType) { pOfferPriceTypeInfo.offerPriceTypeId = pOfferPriceType.OfferPriceTypeId; pOfferPriceTypeInfo.offerPriceTypeName = pOfferPriceType.OfferPriceTypeName; pOfferPriceTypeInfo.Loaded = true; }
//数据持久化 internal static void SaveToDb(OfferPriceTypeInfo pOfferPriceTypeInfo, OfferPriceType pOfferPriceType,bool pIsNew) { pOfferPriceType.OfferPriceTypeId = pOfferPriceTypeInfo.offerPriceTypeId; pOfferPriceType.OfferPriceTypeName = pOfferPriceTypeInfo.offerPriceTypeName; pOfferPriceType.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOfferPriceType.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(OfferPriceTypeInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOfferPriceTypeInfo.offerPriceTypeId = pOfferPriceType.OfferPriceTypeId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OfferPriceTypeInfo))) { ResetCache(); } }