zoukankan      html  css  js  c++  java
  • ActiveRecord group by query

    One day , I need use "group by " query,
    but i don't know how to write it on ActiveRecord,

    I try mony method, but i can't get the results. i am also post a thread to forum of caslte, but no one replay it ,may be it is so easy.
    so ,  i redo my work. i found ,
    i can use
                "select table.name,count(table.name) from Table table group by table.name order by table count(table.name) desc"
    My gold, Is correct now.

    HqlBasedQuery query = new HqlBasedQuery(typeof(ActivityInfo), hql);
                
    return ExecuteQuery(query);

    How to get the data? like below
     ArrayList list = o as ArrayList;
            
    for(int i=0;i<list.Count;i++)
            
    {
               
    object[] list2 = list[i] as object[];
            }

    and I found in activeRecord you can use SQL language to query, just set QueryLanguage to sql,

    anthor method: Navtie Query
    ISessionFactoryHolder sessionHolder = ActiveRecordMediator.GetSessionFactoryHolder(); ISession session = sessionHolder.CreateSession(typeof(Synonym)); try string query = ""; IQuery sqlQuery = session.CreateSQLQuery(query, "Synonym"typeof(Synonym)); sqlQuery.SetMaxResults(10); return sqlQuery.List(); } finally { sessionHolder.ReleaseSession(session); } 

  • 相关阅读:
    时间段内随机生成日期函数
    已知目标qps跟并发用户数20,压测平均响应时间实例
    并发数 = QPS*平均响应时间
    性能测试实战-XYB项目-内网访问
    linux安装jmeter
    word设置
    nginx安装【windows下安装】
    mac 修改权限为当前用户用户组
    兼容性测试
    linux 的一些命令
  • 原文地址:https://www.cnblogs.com/lovebanyi/p/820843.html
Copyright © 2011-2022 走看看