本文整理汇总了C#中MessageCollection.LoadAndCloseReader方法的典型用法代码示例。如果您正苦于以下问题:C# MessageCollection.LoadAndCloseReader方法的具体用法?C# MessageCollection.LoadAndCloseReader怎么用?C# MessageCollection.LoadAndCloseReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageCollection
的用法示例。
在下文中一共展示了MessageCollection.LoadAndCloseReader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPagedList
/// <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<MessageInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
{
if(pPageIndex<=1)
pPageIndex=1;
List< MessageInfo> list = new List< MessageInfo>();
Query q = Message .CreateQuery();
q.PageIndex = pPageIndex;
q.PageSize = pPageSize;
q.ORDER_BY(pSortExpression,pOrderBy.ToString());
MessageCollection collection=new MessageCollection();
collection.LoadAndCloseReader(q.ExecuteReader());
foreach (Message message in collection)
{
MessageInfo messageInfo = new MessageInfo();
LoadFromDAL(messageInfo, message);
list.Add(messageInfo);
}
pRecordCount=q.GetRecordCount();
return list;
}
示例2: GetList
/// <summary>
/// 获得数据列表
/// </summary>
/// <returns></returns>
public static List<MessageInfo> GetList()
{
string cacheKey = GetCacheKey();
//本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
if (CachedEntityCommander.IsTypeRegistered(typeof(MessageInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
{
return CachedEntityCommander.GetCache(cacheKey) as List< MessageInfo>;
}
else
{
List< MessageInfo> list =new List< MessageInfo>();
MessageCollection collection=new MessageCollection();
Query qry = new Query(Message.Schema);
collection.LoadAndCloseReader(qry.ExecuteReader());
foreach(Message message in collection)
{
MessageInfo messageInfo= new MessageInfo();
LoadFromDAL(messageInfo,message);
list.Add(messageInfo);
}
//生成缓存
if (CachedEntityCommander.IsTypeRegistered(typeof(MessageInfo)))
{
CachedEntityCommander.SetCache(cacheKey, list);
}
return list;
}
}