Search is now implemented (+ other forum updates)

Posts   
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 20-Jan-2004 15:58:49   

I've implemented a temp-search solution which will allow you to search on the forum. Click the 'search' menu option at the top for details simple_smile . It doesn't have paging yet, so it limits the amount of results to 75 rows.

I've also fixed some bugs and generated new LR(1) parser tables which now allows you to use the [img]tags, which was buggy before.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 20-Jan-2004 16:02:11   

For the people interested, I needed a fieldrange predicate (WHERE FIELD IN (...) ). It's listed below. It will be added in the future to the runtime library. This version is not adapter compatible.


using System;
using System.Text;
using System.Data;
using System.Collections;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace SD.CESys.TinyForum.DALPro.CustomPredicates
{
    /// <summary>
    /// Implementation of a Field compare-range Values expression, using the following format:
    /// IEntityField(Core) ComparisonOperator Parameters (f.e. Foo IN (@Foo1, @Foo2 ... ))
    /// There is no check for types between the value specified and the specified IEntityField.
    /// </summary>
    [Serializable]
    public class FieldCompareRangePredicate : Predicate
    {
        #region Class Member Declarations
        private IEntityField            _field;
        private ArrayList               _values;
        #endregion

        /// <summary>
        /// CTor
        /// </summary>
        public FieldCompareRangePredicate()
        {
            InitClass(null, false, new object[0]);
        }


        /// <summary>
        /// CTor. Creates Field IN (values) clause
        /// </summary>
        /// <param name="field">Field used in the comparison expression</param>
        /// <param name="values">Value range to set for the IN clause. Specify any range of values.</param>
        public FieldCompareRangePredicate(IEntityField field, bool negate, params object[] values)
        {
            InitClass(field, negate, values);
        }


        /// <summary>
        /// Implements the IPredicate ToQueryText method. Retrieves a ready to use text representation of the contained Predicate.
        /// </summary>
        /// <param name="uniqueMarker">int counter which is appended to every parameter. The refcounter is increased by every parameter creation,
        /// making sure the parameter is unique in the predicate and also in the predicate expression(s) containing the predicate.</param>
        /// <returns>The contained Predicate in textual format.</returns>
        /// <exception cref="System.ApplicationException">When IPredicate.DatabaseSpecificCreator is not set to a valid value.</exception>
        public override string ToQueryText(ref int uniqueMarker)
        {
            if(_field==null)
            {
                return "";
            }

            if(_values.Count<=0)
            {
                return "";
            }

            if(base.DatabaseSpecificCreator==null)
            {
                throw new System.ApplicationException("DatabaseSpecificCreator object not set. Cannot create query part.");
            }

            base.Parameters.Clear();

            StringBuilder queryText = new StringBuilder(128);
            
            queryText.AppendFormat("{0} ", base.DatabaseSpecificCreator.CreateFieldName(_field));

            if(base.Negate)
            {
                queryText.Append("NOT ");
            }

            queryText.Append("IN (");

            // create parameters, one for each value
            for (int i = 0; i < _values.Count; i++)
            {
                if(i>0)
                {
                    queryText.Append(", ");
                }

                IDataParameter parameter = base.DatabaseSpecificCreator.CreateParameter(_field, ParameterDirection.Input);
                base.Parameters.Add(parameter);
                uniqueMarker++;
                parameter.Value = _values[i];
                parameter.ParameterName += uniqueMarker.ToString();

                queryText.Append(parameter.ParameterName);
            }
            queryText.Append(")");
            return queryText.ToString();
        }


        /// <summary>
        /// Initializes the class.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="negate"></param>
        /// <param name="values"></param>
        private void InitClass(IEntityField field, bool negate, params object[] values)
        {
            _field = field;
            _values = new ArrayList();
            for (int i = 0; i < values.Length; i++)
            {
                _values.Add(values[i]);
            }
            base.Negate=negate;
        }


        #region Class Property Declarations
        /// <summary>
        /// Field used in the comparison expression (SelfServicing).
        /// </summary>
        /// <exception cref="InvalidOperationException">if this object was constructed using a non-selfservicing constructor.</exception>
        public virtual IEntityField Field
        {
            get 
            { 
                return (IEntityField)_field; 
            }
        }

        /// <summary>
        /// Values to set for the IN Clause
        /// </summary>
        public virtual ArrayList Values
        {
            get { return _values; }
            set { _values = value; }
        }
        #endregion
        
    }
}

Frans Bouma | Lead developer LLBLGen Pro
bertcord avatar
bertcord
User
Posts: 206
Joined: 01-Dec-2003
# Posted on: 20-Jan-2004 19:30:14   

Otis wrote:

I've implemented a temp-search solution which will allow you to search on the forum.

stuck_out_tongue_winking_eye stuck_out_tongue_winking_eye stuck_out_tongue_winking_eye stuck_out_tongue_winking_eye

awesome thansk so much. And I also think you will save yourself some time now. This forums is a wealth of information!

swallace
User
Posts: 648
Joined: 18-Aug-2003
# Posted on: 21-Jan-2004 15:18:11   

Love the new IN predicate! Looking forward to using it, got some code I can go back on and reduce lines with it.

Have to take the opportunity to ask, is there a point when we can expect support for full-text queries? I'm suprised you didn't break down and put it in for this purpose.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 21-Jan-2004 15:44:55   

swallace wrote:

Love the new IN predicate! Looking forward to using it, got some code I can go back on and reduce lines with it.

simple_smile

Have to take the opportunity to ask, is there a point when we can expect support for full-text queries? I'm suprised you didn't break down and put it in for this purpose.

Full text queries are sqlserver specific, which was one reason why I didn't put it in the first release, because the generic library would then not be generic. THere are other predicates to think of which also would be nice in the library, so I'll add them with the first revision of the new lib, which will be when SelfServicing gets the new features Adapter has already (which is within a month).

Other predicates are for example: field compare field FreeSQLPredicate, where you can construct hard core SQL. (not that recommended, but some people want it simple_smile ).

FieldCompareField is a bit limited also, as expressions are not yet supported. (field + 10 - field3 + sum (field4) etc.. wink ), however it can be useful.

Frans Bouma | Lead developer LLBLGen Pro
swallace
User
Posts: 648
Joined: 18-Aug-2003
# Posted on: 22-Jan-2004 03:19:33   

Sweeet.

bertcord avatar
bertcord
User
Posts: 206
Joined: 01-Dec-2003
# Posted on: 22-Jan-2004 17:37:29   

Many of the applications I support use bitwise fields. Any plans on addding bitwise operators

& (Bitwise AND) ~ (Bitwise NOT) | (Bitwise OR) ^ (Bitwise Exclusive OR)

bert

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 22-Jan-2004 17:52:56   

Good point, bitwise operations.

However, in theory, Oracle for example, doesn't support bit based fields, so this can be a problem too.

But you mean you have for example a 32bit field and you want to filter on those fields using a mask?

Frans Bouma | Lead developer LLBLGen Pro
bertcord avatar
bertcord
User
Posts: 206
Joined: 01-Dec-2003
# Posted on: 22-Jan-2004 21:39:43   

Otis wrote:

Oracle for example, doesn't support bit based fields, so this can be a problem too.

But you mean you have for example a 32bit field and you want to filter on those fields using a mask?

o yeah Oracle that other databse smile

We use these fields to track two-valued attributes. For example

instead of adding columns bFoo1,Foo2,bFoo3,bFoo4 we would add one column of integer datatype.

bFoo1 - Bit Value = 1 bFoo2 - Bit Value = 2 bFoo3 - Bit Value = 4 bFoo4 - Bit Value = 8

A query to retrieve these values would look something like this

SELECT
CASE WHEN (1 & StatusVector) = 0 THEN 0 ELSE 1 END AS bFoo1 , --BitPlace 0 CASE WHEN (2 & StatusVector) = 0 THEN 0 ELSE 1 END AS bFoo2 , --BitPlace 1 CASE WHEN (4 & StatusVector) = 0 THEN 0 ELSE 1 END AS bFoo3 , --BitPlace 2 CASE WHEN (8 & StatusVector) = 0 THEN 0 ELSE 1 END AS bFoo4 , --BitPlace 3 FROM .....

I would like to use the 2 class project. In by inherited classes I would perform the bitwise operations, but I still would like to use the bitwise predicate to filter the results.