Help needed to create a custom sql query

Posts   
 
    
idrees
User
Posts: 19
Joined: 01-Feb-2007
# Posted on: 01-Feb-2007 01:25:42   

Hi there

I am new to this company and they are currently using LLBL Gen Pro ver 1.0.2005.1 Final.

I have just started learning LLBL. Meanwhile, can you help me to understand how to create a custom query especially like the one below: select name, max(year) as year from qualification group by name

Thanks in advance.

Idrees

idrees
User
Posts: 19
Joined: 01-Feb-2007
# Posted on: 01-Feb-2007 02:42:12   

To be more specific, the following is what I need to achieve:

The following method returns a search result which has to be modified to retrieve result similar to the sql query - "select name, max(year) as year from qualification group by name"


        protected override IPredicateExpression GetSearchPredicate()
        {
            PredicateExpression search = new PredicateExpression();         

            if(txtName.Text.Trim() != string.Empty)
                search.AddWithAnd(PredicateFactory.Like(QualificationFieldIndex.Name, "%" + txtName.Text + "%"));
            if(txtCode.Text.Trim() != string.Empty)
                search.AddWithAnd(PredicateFactory.Like(QualificationFieldIndex.QualificationCode, "%" + txtCode.Text + "%"));
            if(ucCertType.SelectedValue != string.Empty)
                search.AddWithAnd(PredicateFactory.CompareValue(QualificationFieldIndex.CertificationTypeId, ComparisonOperator.Equal, int.Parse(ucCertType.SelectedValue)));
            if(txtYear.Text != string.Empty && Utils.IsNumeric(txtYear.Text))
            {
                int year = int.Parse(txtYear.Text);
                if (year < 100)
                {
                    year += 2000;
                    if (year > DateTime.Now.Year)
                        year -= 100;
                }
                                
                search.AddWithAnd(PredicateFactory.CompareValue(QualificationFieldIndex.Year, ComparisonOperator.Equal, year));
            }
            return search;
        }

Thanks in advance.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Feb-2007 04:29:11   

Can you take a look at http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8876 to see if that answer helps? I'll close this one in the meantime.