Example #1
0
        /// <summary>
        /// Get data for build expression.
        /// </summary>
        /// <param name="searchInfo">The search info.</param>
        /// <returns></returns>
        private void GetDataForBuildExpression(SearchInfo searchInfo)
        {
            var properties = searchInfo.GetType().GetProperties();

            foreach (var property in properties)
            {
                var expressionBuilderAttribute = (ExpressionBuilderAttribute)property.GetCustomAttribute(typeof(ExpressionBuilderAttribute));

                if (expressionBuilderAttribute != null)
                {
                    var value = property.GetValue(searchInfo);

                    if (value != null)
                    {
                        var filterStatement = new FilterStatement
                        {
                            PropertyName = expressionBuilderAttribute.PropertyName,
                            Operation    = expressionBuilderAttribute.Operation,
                            Value        = value
                        };

                        _statements.Add(filterStatement);
                    }
                }
            }
        }