public ActionResult List(GridCommand command, TraceLogSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     if (searchCacheModel.isBack == true)
     {
         ViewBag.Page = searchCacheModel.Command.Page==0 ? 1 : searchCacheModel.Command.Page;
     }
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }
 public ActionResult _AjaxList(GridCommand command, TraceLogSearchModel searchModel)
 {
     this.GetCommand(ref command, searchModel);
     SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<TraceLog>(searchStatementModel, command));
 }
        /// <summary>
        /// Search Statement
        /// </summary>
        /// <param name="command">Telerik GridCommand</param>
        /// <param name="searchModel">Address Search Model</param>
        /// <returns>return address search model</returns>
        private SearchStatementModel PrepareSearchStatement(GridCommand command, TraceLogSearchModel searchModel)
        {            
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();

            HqlStatementHelper.AddEqStatement("EntityTable", searchModel.Table, "t", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Operator", searchModel.OperatorType, "t", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("PostCode", searchModel.PostCode, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("TelPhone", searchModel.TelPhone, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("MobilePhone", searchModel.MobilePhone, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("Fax", searchModel.Fax, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("Email", searchModel.Email, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddLikeStatement("ContactPersonName", searchModel.ContactPersonName, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            //HqlStatementHelper.AddEqStatement("Type", searchModel.Type, "u", ref whereStatement, param);

            if (searchModel.DateFrom != null & searchModel.DateTo != null)
            {
                HqlStatementHelper.AddBetweenStatement("OperateDate", searchModel.DateFrom, searchModel.DateTo, "t", ref whereStatement, param);
            }
            else if (searchModel.DateFrom != null & searchModel.DateTo == null)
            {
                HqlStatementHelper.AddGeStatement("OperateDate", searchModel.DateFrom, "t", ref whereStatement, param);
            }
            else if (searchModel.DateFrom == null & searchModel.DateTo != null)
            {
                HqlStatementHelper.AddLeStatement("OperateDate", searchModel.DateTo, "t", ref whereStatement, param);
            }

            //if (command.SortDescriptors.Count > 0)
            //{
            //    if (command.SortDescriptors[0].Member == "AddressTypeDescription")
            //    {
            //        command.SortDescriptors[0].Member = "Type";
            //    }
            //}
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }