Ejemplo n.º 1
0
        private static abstractSearch CreateSearchCriteria(Type type, string property)
        {
            abstractSearch result = null;

            if (type.Equals(typeof(string)))
            {
                result = new textSearch();
            }
            else if (type.Equals(typeof(int)) || type.Equals(typeof(int?)))
            {
                result = new intSearch();
            }
            else if (type.Equals(typeof(decimal)) || type.Equals(typeof(decimal?)))
            {
                result = new decimalSearch();
            }
            else if (type.Equals(typeof(DateTime)) || type.Equals(typeof(DateTime?)))
            {
                result = new dateSearch();
            }

            if (result != null)
            {
                result.property = property;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static string filterTextValue(this ICollection <abstractSearch> filter, string property)
        {
            string result = string.Empty;

            try
            {
                textSearch ds = filter.Where(x => x.property.ToLower() == property.ToLower()).FirstOrDefault() as textSearch;

                if (ds != default(textSearch))
                {
                    result = ds.searchTerm;
                }
            }
            catch (ArgumentNullException ex)
            {
                throw new ArgumentNullException(string.Format("Property '{0}' not found.", property), ex);
            }

            return(result);
        }