Exemple #1
0
        private VolumeItem[] _SearchItem(ISearchCriteria searchCriteria)
        {
            // TODO : check SQL output! implemetation was rewritten from scratch!!
            // TODO : VolumeDatabase shouln't hardcode fieldnames or tablenames
            //const string ORDER_FIELD = "Items.VolumeID"; // slows down searching drastically

            /*** build sql query ***/
            string condition = searchCriteria.GetSqlSearchCondition();

            if (condition.Length == 0)             // e.g. empty SearchCriteriaGroup
            {
                throw new ArgumentException("SearchCriteria is empty", "searchCriteria");
            }

            string sqlQuery;

            if ((searchCriteria.SearchCriteriaType & SearchCriteriaType.VolumeSearchCriteria) == SearchCriteriaType.VolumeSearchCriteria)
            {
                // searchriteria contains volume searchriteria -> join volumes table
                sqlQuery = string.Format("SELECT Items.* FROM Items, Volumes WHERE ({0}) AND (Items.VolumeID = Volumes.VolumeID);", condition);
            }
            else
            {
                //sqlQuery = string.Format("SELECT * FROM Items WHERE {0} ORDER BY {1};", condition, ORDER_FIELD);
                sqlQuery = string.Format("SELECT * FROM Items WHERE {0};", condition);
            }

            if (Global.EnableDebugging)
            {
                Debug.WriteLine(string.Format("_SearchItem() executes query: '{0}'", sqlQuery));
            }

            return(QueryItems <VolumeItem>(sqlQuery, searchItemResultsLimit));
        }
Exemple #2
0
        private Volume[] _SearchVolume(ISearchCriteria searchCriteria)
        {
            // TODO : check SQL output! implemetation was rewritten from scratch!!
            // TODO : VolumeDatabase shouln't hardcode fieldnames or tablenames
            // TODO : Volume.TableName, Volume.IDField?
            //const string ORDER_FIELD = "Volumes.VolumeID"; // slows down searching

            /*** build sql query ***/
            string sqlQuery;

            //sqlQuery = string.Format("SELECT * FROM Volumes WHERE {0} ORDER BY {1};", condition, ORDER_FIELD);

            if (searchCriteria == null)
            {
                // when searching volumes, the searchcriteria may be optional
                // since the resultset can not become as big as in in item searches.
                // apart from that there must be a way to retrieve all volumes in the database.
                sqlQuery = "SELECT * FROM Volumes;";
            }
            else
            {
                string condition = searchCriteria.GetSqlSearchCondition();

                if (condition.Length == 0)                 // e.g. empty SearchCriteriaGroup
                {
                    throw new ArgumentException("SearchCriteria is empty", "searchCriteria");
                }

                if ((searchCriteria.SearchCriteriaType & SearchCriteriaType.ItemSearchCriteria) == SearchCriteriaType.ItemSearchCriteria)
                {
                    // searchriteria contains item searchriteria -> join items table
                    sqlQuery = string.Format("SELECT DISTINCT Volumes.* FROM Volumes, Items WHERE ({0}) AND (Volumes.VolumeID = Items.VolumeID);", condition);
                }
                else
                {
                    sqlQuery = string.Format("SELECT * FROM Volumes WHERE {0};", condition);
                }
            }

            if (Global.EnableDebugging)
            {
                Debug.WriteLine(string.Format("_SearchVolume() executes query: '{0}'", sqlQuery));
            }

            return(QueryVolumes(sqlQuery));
        }
 string ISearchCriteria.GetSqlSearchCondition()
 {
     return(string.Format("NOT ({0})", searchCriteria.GetSqlSearchCondition()));
 }
 string ISearchCriteria.GetSqlSearchCondition()
 {
     return(searchCriteria.GetSqlSearchCondition());
 }