protected virtual List <string> BuildQuery()
        {
            List <string> conditions = new List <string>();
            Dictionary <string, RestConditionAttribute> map = GetConditionsMap();

            Type type = GetType();

            foreach (string key in map.Keys)
            {
                RestConditionAttribute conditionAttribute = map[key];
                PropertyInfo           property           = type.GetProperty(key);
                object value = RestDatabase.ToQueryValue(property.GetValue(this));
                if (value != null)
                {
                    string condition = string.Format("{0} {1} {2}", conditionAttribute.Name, conditionAttribute.Operator, value);
                    conditions.Add(condition);
                }
            }

            return(conditions);
        }
        private Dictionary <string, RestConditionAttribute> GetConditionsMap()
        {
            Type type = GetType();

            if (!conditionsMaps.ContainsKey(type))
            {
                Dictionary <string, RestConditionAttribute> map = new Dictionary <string, RestConditionAttribute>();
                foreach (PropertyInfo property in type.GetProperties())
                {
                    RestConditionAttribute conditionAttribute = property.GetCustomAttribute <RestConditionAttribute>();
                    if (conditionAttribute != null)
                    {
                        map[property.Name] = conditionAttribute;
                    }
                }

                conditionsMaps[type] = map;
            }

            return(conditionsMaps[type]);
        }