Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > General> where x in (1121,1331,1441,1551,1661)
 

Pages: 1
General
where x in (1121,1331,1441,1551,1661)
Page:1/1 

  Print all messages in this thread  
Poster Message
tvoss
User



Location:
Spokane, WA USA
Joined on:
07-Dec-2003 11:23:34
Posted:
192 posts
# Posted on: 25-Nov-2009 18:44:31.  
Hello,

I have a wierd set of data I have to retrieve at once with one filter so that I can page it to a datagrid with your easy paging.

the data after the 'in' I cannot get from a filter since it is customer input from a web form, so it will be in the form of a list or collection or string or whatever I can easily create knowing what those numbers are.

How can I do a filter with the above without the resulting list of integers being a filter?

I hope that is clear.

Thanks,
Terry Voss
Terry Voss  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
7600 posts
# Posted on: 26-Nov-2009 04:11:03.  
Hi Terry,

If I understand you you have a set of strings from the user input, then you want to use that to create a IN filter but with numbers, right?

If that is correct, you should:

1. Convert the user input to something usable. For instance, if the user enters a comma separated string you can use some method like:

Code:
static int[] SplitStringIntoInts(string list)
{
    List<int> numbers = new List<int>();
    foreach (string stringValue in list.Split(','))
    {
        int number;
        if (int.TryParse(stringValue, out number))
        {
            numbers.Add(number);
        }
    }

    return numbers.ToArray();
}


or whatever method you use to transform such user input into usable numbers.

2. Then you can easily create a filter that create the IN predicate. This is the easiest way:

Code:
string list = theUserInput;
int[] numbers = SplitStringIntoInts(list);

myPredicate.Add(OrderFieldsOrderId == numbers);

// fetch..., etc


Hope I understood what you really want.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.