//
        private static void SetPropertiesFilter(MainSearchInput data, ref string where)
        {
            string AND = "";
            string searchCategories = UtilityManager.GetAppKeyValue("asmtSearchCategories", "21,37,");

            SearchServices.SetPropertiesFilter(data, 1, searchCategories, ref where);
            //string template = " ( base.Id in ( SELECT  [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 3 AND {0} )) ";
            //string template1 = " ( base.Id in ( SELECT  [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 3 AND [PropertyValueId] in ({0}) )) ";
            //string properyListTemplate = " ( [PropertyValueId] in ({0}) ) ";
            //string filterList = "";
            //int prevCategoryId = 0;

            ////Updated to use FiltersV2
            //string next = "";
            //if (where.Length > 0)
            //    AND = " AND ";
            //foreach (var filter in data.FiltersV2.Where(m => m.Type == MainSearchFilterV2Types.CODE))
            //{
            //    var item = filter.AsCodeItem();
            //    if (searchCategories.Contains(item.CategoryId.ToString()))
            //    {
            //        //18-03-27 mp - these are all property values, so using an AND with multiple categories will always fail - removing prevCategoryId check
            //        //if (item.CategoryId != prevCategoryId)
            //        //{
            //        //    if (prevCategoryId > 0)
            //        //    {
            //        //        next = next.Trim(',');
            //        //        filterList += (filterList.Length > 0 ? " AND " : "") + string.Format(properyListTemplate, next);
            //        //    }
            //        //    prevCategoryId = item.CategoryId;
            //        //    next = "";
            //        //}
            //        next += item.Id + ",";
            //    }
            //}
            //next = next.Trim(',');
            //if (!string.IsNullOrWhiteSpace(next))
            //{
            //    //where = where + AND + string.Format( template, next );
            //    filterList += (filterList.Length > 0 ? " AND " : "") + string.Format(properyListTemplate, next);
            //    where = where + AND + string.Format(template, filterList);
            //}
        } //
        /// <summary>
        /// determine which results a user may view, and eventually edit
        /// </summary>
        /// <param name="data"></param>
        /// <param name="user"></param>
        /// <param name="where"></param>

        private static void SetPropertiesFilter(MainSearchInput data, ref string where)
        {
            string searchCategories = UtilityManager.GetAppKeyValue("orgSearchCategories", "7,8,9,30,");

            SearchServices.SetPropertiesFilter(data, 1, searchCategories, ref where);
        }
        private static void SetPropertiesFilter(MainSearchInput data, ref string where)
        {
            string AND = "";
            string searchCategories = UtilityManager.GetAppKeyValue("credSearchCategories", "21,37,");

            SearchServices.SetPropertiesFilter(data, 1, searchCategories, ref where);
            //string template1 = " ( base.Id in ( SELECT  [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 1 AND [PropertyValueId] in ({0}))) ";
            //string template = " ( base.Id in ( SELECT  [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 1 AND {0} )) ";
            //string credTypes = " ( base.CredentialTypeId in ({0}) ) ";

            //string properyListTemplate = " ( [PropertyValueId] in ({0}) ) ";
            //string filterList = "";
            //int prevCategoryId = 0;
            ////Updated to use FiltersV2
            //string next = "";
            //string typesFilter = "";
            //if ( where.Length > 0 )
            //    AND = " AND ";

            //var credSearchCategories = new List<int>();
            //foreach ( var s in searchCategories.Split( ',' ) )
            //    if ( !string.IsNullOrEmpty( s ) )
            //        credSearchCategories.Add( int.Parse( s ) );

            //foreach ( var filter in data.FiltersV2.Where( m => m.Type == MainSearchFilterV2Types.CODE ).ToList() )
            //{
            //    var item = filter.AsCodeItem();
            //    //if ( searchCategories.Contains( item.CategoryId.ToString() ) )
            //    if ( credSearchCategories.Contains( item.CategoryId ) )
            //    {
            //        if ( item.CategoryId == 2 )
            //        {
            //            typesFilter += item.Id + ",";
            //        }
            //        else
            //        {
            //            //18-03-27 mp - these are all property values, so using an AND with multiple categories will always fail - removing prevCategoryId check
            //            //if (item.CategoryId != prevCategoryId)
            //            //{
            //            //    if (prevCategoryId > 0)
            //            //    {
            //            //        next = next.Trim(',');
            //            //        filterList += (filterList.Length > 0 ? " AND " : "") + string.Format(properyListTemplate, next);
            //            //    }
            //            //    prevCategoryId = item.CategoryId;
            //            //    next = "";
            //            //}
            //            next += item.Id + ",";
            //        }
            //    }
            //}
            //next = next.Trim( ',' );
            //typesFilter = typesFilter.Trim( ',' );
            //if ( !string.IsNullOrWhiteSpace( next ) )
            //{
            //    //where = where + AND + string.Format( template, next );
            //    filterList += ( filterList.Length > 0 ? " AND " : "" ) + string.Format( properyListTemplate, next );
            //    where = where + AND + string.Format( template, filterList );
            //    AND = " AND ";
            //}
            //if ( !string.IsNullOrWhiteSpace( typesFilter ) )
            //{
            //    where = where + AND + string.Format( credTypes, typesFilter );
            //    AND = " AND ";
            //}

            /* //Retained for reference
             * foreach ( MainSearchFilter filter in data.Filters)
             * {
             *      if ( searchCategories.IndexOf( filter.CategoryId.ToString() ) > -1 )
             *      {
             *              string next = "";
             *              if ( where.Length > 0 )
             *                      AND = " AND ";
             *              foreach ( string item in filter.Items )
             *              {
             *                      next += item + ",";
             *              }
             *              next = next.Trim( ',' );
             *              where = where + AND + string.Format( template, next );
             *      }
             * }
             */
        }