NHibernate??????sql°??±?????????á??×??????è??·????à?????????à??

public IList<ShopDownloadAmountEntity> GetDayByShopBetween(int shopID, DateTime startTime, DateTime endTime)
{
StringBuilder sb = new StringBuilder();
sb.Append("SELECT sum(sizeamount) as SizeAmount,[ShopID],");

sb.Append("dateadd(hh, – datepart(hour,downloadtime) % 24 ,downloadtime) as DownloadTime ");
sb.Append("FROM ShopDownloadAmount ");
sb.Append("WHERE downloadtime between ‘" + startTime + "’ and ‘" + endTime + "’");
sb.Append(" GROUP BY shopid, dateadd(hh, – datepart(hour,downloadtime) % 24 ,downloadtime) ");
sb.Append(" order by dateadd(hh, – datepart(hour,downloadtime) % 24 ,downloadtime)");//sql string

ISQLQuery sql = NHibernateSession.CreateSQLQuery(sb.ToString());
sql.AddScalar("SizeAmount", NHibernateUtil.Int32);//set type of data
sql.AddScalar("ShopID", NHibernateUtil.Int32);
sql.AddScalar("DownloadTime", NHibernateUtil.DateTime);
sql.SetResultTransformer(Transformers.AliasToBean(typeof(ShopDownloadAmountEntity)));//make the result set to entity
return sql.List<ShopDownloadAmountEntity>();
}
ShopDownloadAmountEntity???????à??SizeAmount??ShopID??DownloadTime??setter

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注