Ejemplo n.º 1
0
        /// <summary>
        /// Return the data table which satisfy the search criteria.
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="combineSearch"></param>
        /// <returns></returns>
        public DataTable CombineSearchRecord(DataTable dataTable, CombineSearch combineSearch)
        {
            if (combineSearch.Operator == "&&")
            {
                foreach (var search in combineSearch.SearchList)
                {
                    if (dataTable.AsEnumerable().Count() == 0)
                    {
                        break;
                    }
                    dataTable = search.SearchRecord(dataTable, search);
                }
            }
            else if (combineSearch.Operator == "||")
            {
                var results      = new List <DataTable>();
                var searchresult = new DataTable();
                foreach (var search in combineSearch.SearchList)
                {
                    if (dataTable.AsEnumerable().Count() == 0)
                    {
                        break;
                    }
                    results.Add(search.SearchRecord(dataTable, search));
                }
                foreach (var result in results)
                {
                    searchresult.Merge(result);
                }
                dataTable = searchresult;
            }

            return(dataTable);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the record from file by providing the combine search.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <T> GetRecords <T>(CombineSearch search) where T : new()
        {
            var dataTable = fileRecords;

            if (search != null)
            {
                dataTable = combinSearch.CombineSearchRecord(dataTable, search);
                return(converter.ConvertToType <T>(dataTable));
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method is Generic CSV file reader which will read the data and return list of records which fulfill the combine Search criteria.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filePath"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="search"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public List <T> GetRecords <T>(int pageSize, int pageNumber, CombineSearch search, params string[] filter) where T : new()
        {
            var dataTable = fileRecords;

            if (search != null)
            {
                dataTable = combinSearch.CombineSearchRecord(dataTable, search);
            }
            if (dataTable != null && dataTable.AsEnumerable().Count() != 0)
            {
                var dataView = new DataView(dataTable);
                if (filter != null)
                {
                    dataTable = dataView.ToTable(true, filter);
                }
            }
            if (pageSize != 0 && pageNumber != 0)
            {
                dataTable = pagination.ApplyPaging(pageSize, pageNumber, dataTable);
            }
            return(converter.ConvertToType <T>(dataTable));
        }