dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Building Linq Query on the Fly

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [RESOLVED] Building Linq Query on the Fly

    Hi All,

    I want to create a Linq Statement in the form:

    Code:
    Var xxxx = from word in words Where word.Name.Contains(yyy) || word.Name Contains(zzz)...... select word;
    basically a string is passed with 1..n words. I split the string into an array and I've build a StringBuilder object of the form:

    Code:
    foreach (string s in stringpassed.Split(' '))
    {
     stringbuilder.Append("word.Name.Contains(" + s + ") || ");
    }
    String innerString = stringbuilder.ToString(0,stringbuilder.Length - 3)
    So I now want to end up with :

    Code:
    Var xxxx = from word in words Where innerString select word

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Building Linq Query on the Fly

    Code:
    var xxxx = from word in words where stringpassed.Split(' ').Any(sp => word.Name.Contains(sp))
    I think. (can't test on the machine i'm on).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width