public void setModel(string searchQ, CommonModel <T> model, List <string> colName, int page = 1, int pageSize = 10)
        {
            model.Filters = model.Filters == null ? new List <GridFilter>() : model.Filters;
            foreach (var item in colName) //(var item in col)
            {
                if (model.Filters != null)
                {
                    var obj = model.Filters.FirstOrDefault(d => d.ColumnName == item);
                    if (obj == null)
                    {
                        obj = new GridFilter {
                            ColumnName = item
                        };
                        model.Filters.Add(obj);
                    }
                }
            }

            model.Filters = model.Filters.OrderBy(d => colName.IndexOf(d.ColumnName)).ToList();
            int totalCount = 0;
            int pIndex     = model.page.HasValue ? model.page.Value - 1 : 0;
            var list       = GetDynamicList(searchQ.ToString(), ref totalCount, pIndex, pageSize).ToList();

            var pagedList = new StaticPagedList <dynamic>(list, page, pageSize, totalCount).GetMetaData();

            model.dynamicList         = list;
            model.dynamicListMetaData = pagedList;
        }
        public void setModel(StringBuilder searchQ, CommonModel <T> model, List <string> colName, string sortFieldName, int page = 1, int pageSize = 10)
        {
            model.Filters = model.Filters == null ? new List <GridFilter>() : model.Filters;

            searchQ.Append(" WHERE ");
            searchQ.Append(CommonFunction.GenerateFilterCondition(model.Filters));

            if (!string.IsNullOrWhiteSpace(model.fieldName) && !string.IsNullOrWhiteSpace(model.sortOrder))
            {
                searchQ.Append(" ORDER BY " + model.fieldName + " " + model.sortOrder);
            }
            else
            {
                searchQ.Append(" ORDER BY " + sortFieldName);
            }

            foreach (var item in colName)
            {
                if (model.Filters != null)
                {
                    var obj = model.Filters.FirstOrDefault(d => d.ColumnName == item);
                    if (obj == null)
                    {
                        obj = new GridFilter {
                            ColumnName = item
                        };
                        model.Filters.Add(obj);
                    }
                }
            }

            model.Filters = model.Filters.OrderBy(d => colName.IndexOf(d.ColumnName)).ToList();
            int totalCount = 0;
            int pIndex     = model.page.HasValue ? model.page.Value - 1 : 0;
            var list       = GetDynamicList(searchQ.ToString(), ref totalCount, pIndex, pageSize).ToList();

            var pagedList = new StaticPagedList <dynamic>(list, page, pageSize, totalCount).GetMetaData();

            model.dynamicList         = list;
            model.dynamicListMetaData = pagedList;
        }