TypedList with null parameter returns

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 26-Oct-2013 08:02:20   

LLBLGEN 4.0 SQL 2008

In the below code, if I pass description as an empty string, it returns all records. Is there a way to return 0 records in case of empty input string ?


public static DataView ReturnSearchResult(string description)
        {
            try
            {
                Filter.Clear();
                _sort = null;
                var titleview = new TitleViewTypedList();
                var likepredicate = new FieldLikePredicate(TitleFields.Description.SetObjectAlias("T"),
                                                           ChangeCaseClass.Uppercasestring("%" + description + "%"));
                likepredicate.CaseSensitiveCollation = true;
                Filter.Add(likepredicate);
                Filter.AddWithAnd(new FieldCompareValuePredicate(TitleFields.Flag.SetObjectAlias("T"),
                                                                 ComparisonOperator.Equal,
                                                                 PublicConstantClass.Validflag));
                _sort =
                    new SortExpression(TitleFields.Description.SetObjectAlias("T") | SortOperator.Ascending);
                titleview.Fill(0, _sort, true, Filter);
                return titleview.DefaultView;
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogMessage(ex.Message + ex.StackTrace);
                throw;
            }
        }

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 26-Oct-2013 12:48:31   

shekar wrote:

LLBLGEN 4.0 SQL 2008

In the below code, if I pass description as an empty string, it returns all records. Is there a way to return 0 records in case of empty input string ?


public static DataView ReturnSearchResult(string description)
        {
            try
            {
                Filter.Clear();
                _sort = null;
                var titleview = new TitleViewTypedList();
                var likepredicate = new FieldLikePredicate(TitleFields.Description.SetObjectAlias("T"),
                                                           ChangeCaseClass.Uppercasestring("%" + description + "%"));
                likepredicate.CaseSensitiveCollation = true;
                Filter.Add(likepredicate);
                Filter.AddWithAnd(new FieldCompareValuePredicate(TitleFields.Flag.SetObjectAlias("T"),
                                                                 ComparisonOperator.Equal,
                                                                 PublicConstantClass.Validflag));
                _sort =
                    new SortExpression(TitleFields.Description.SetObjectAlias("T") | SortOperator.Ascending);
                titleview.Fill(0, _sort, true, Filter);
                return titleview.DefaultView;
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogMessage(ex.Message + ex.StackTrace);
                throw;
            }
        }

If this is to be handled by programming language, this thread may be closed please