public List<StudentSearchViewModel> Search(int flag, StudentSearchViewModel entity, int pageIndex, int pageSize, out int totalCount)
        {
            totalCount = 0;
            var objEntityList = new List<StudentSearchViewModel>();
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SPS_STUDENT_VIEWMODEL_SEARCH))
                {
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_KEYWORD, DbType.String, entity.Keyword);

                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_PAGEINDEX, DbType.Int32, pageIndex);
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_PAGESIZE, DbType.Int32, pageSize);
                    objDB.AddOutParameter(sprocCmd, COLUMN_NAME_TOTALCOUNT, DbType.Int32, totalCount);

                    using (IDataReader reader = objDB.ExecuteReader(sprocCmd))
                    {
                        while (reader.Read())
                        {
                            var objEntityViewModel = new StudentSearchViewModel();

                            objEntityViewModel.Id = reader.GetColumnValue<int>(COLUMN_NAME_ID);
                            objEntityViewModel.Name = reader.GetColumnValue<string>(COLUMN_NAME_NAME);

                            objEntityViewModel.Age = reader.GetColumnValue<int>(COLUMN_NAME_AGE);
                            //objEntityViewModel.DOB = reader.GetColumnValue<DateTime>(COLUMN_NAME_DOB);
                            objEntityViewModel.Gender = reader.GetColumnValue<GenderEnum>(COLUMN_NAME_GENDER);

                            if (objEntityViewModel != null)
                            {
                                objEntityList.Add(objEntityViewModel);
                            }
                        }
                    }

                    totalCount = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, COLUMN_NAME_TOTALCOUNT));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntityList;
        }
        public ActionResult SearchWithOutPaging(string Keyword)
        {
            //    Install-Package PagedList.Mvc

            var objEntity = new StudentSearchViewModel()
            {
                Keyword = Keyword
            };

            //
            var objStudentRepository = new StudentSearchRepository();
            objEntity.StudentViewModelList = new List<StudentSearchViewModel>();

            objEntity.StudentViewModelList = objStudentRepository.Search(StudentFlags.SelectAllByKeyword.GetHashCode(), objEntity);

            if (objEntity.StudentViewModelList.Count == 0)
            {
               //flash message
            }

            return View(objEntity);
        }
        public ActionResult Search(int? page, string Keyword)
        {
            //    Install-Package PagedList.Mvc

            var objEntity = new StudentSearchViewModel()
            {
                Name = Keyword
            };
            var pageIndex = (page ?? 1) - 1; //MembershipProvider expects a 0 for the first page
            var pageSize = 2;
            int totalCount; // will be set by call to GetAllUsers due to _out_ paramter :-|
            //
            var objStudentRepository = new StudentSearchRepository();
            objEntity.StudentViewModelList = new List<StudentSearchViewModel>();

            objEntity.StudentViewModelList = objStudentRepository.Search(StudentFlags.SelectAll.GetHashCode(), objEntity, pageIndex, pageSize, out totalCount);

            if (objEntity.StudentViewModelList.Count == 0)
            {

            }

            return View(objEntity);
        }
        public List<StudentSearchViewModel> Search(int flag, StudentSearchViewModel objEntity)
        {
            var objEntityList = new List<StudentSearchViewModel>();
            try
            {
                Database objDB = base.GetDatabase();
                // Create a suitable command type and add the required parameter.
                using (DbCommand sprocCmd = objDB.GetStoredProcCommand(SPS_STUDENT_VIEWMODEL_SEARCHWITHOUTPAGING))
                {
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_FLAG, DbType.String, flag);
                    objDB.AddInParameter(sprocCmd, COLUMN_NAME_KEYWORD, DbType.String, objEntity.Keyword);

                    using (IDataReader reader = objDB.ExecuteReader(sprocCmd))
                    {
                        while (reader.Read())
                        {
                            var objEntityViewModel = new StudentSearchViewModel();

                            objEntityViewModel.Id = reader.GetColumnValue<int>(COLUMN_NAME_ID);
                            objEntityViewModel.Name = reader.GetColumnValue<string>(COLUMN_NAME_NAME);

                            objEntityViewModel.Age = reader.GetColumnValue<int>(COLUMN_NAME_AGE);

                            objEntityViewModel.Gender = reader.GetColumnValue<GenderEnum>(COLUMN_NAME_GENDER);

                            if (objEntityViewModel != null)
                            {
                                objEntityList.Add(objEntityViewModel);
                            }
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return objEntityList;
        }