Multiple keyword search with a LINQ query using the CRM API

One of my customers wanted a simple web service to access CRM data from a web portal he was creating. The normal CRM API was to complex for this so we decided to make a WCF service that connected to CRM via the CRM API. One of the functions he wanted was a multiple keyword search.

var searchfrase = "hebbink com";
var keywords = searchfrase.Split(' ');
var query = AccountSet;

foreach (var x in keywords)
{
    query = query.Where(a => (a.AccountNumber.Contains(x) || a.Name.Contains(x)));
}

var accounts = query.ToList();

foreach (var account in accounts)
{
    Console.Write(account.Name + Environment.NewLine);
}

Just run this piece of code in LINQPad for CRM as a C# Statement and you will get the following result:



Works like a charm :-)

Comments (7) -

  • custom essay writing service

    12/8/2016 4:57:06 AM |

    Thank you for share this information i like this information very much and its very useful to me. i have more some doubts about this API please share more information about this Multiple keyword search with a LINQ query.

  • paper writing service

    2/8/2017 7:14:11 PM |

    That was interesting. Thank you for adding those materials here. I think that some of those aspects are already familiar to us.

  • online essay writers

    4/17/2017 8:50:56 PM |

    I think I should modify it to solve my problem. It would be great if you'll add more curious ideas later.

  • category how to page 4

    5/10/2017 11:50:14 AM |

    The report is pretty clear, so I will find some time to fix my problem. Your clarification on more extended multiple keyword search may be required.

  • eqotuti

    5/12/2017 10:37:39 PM |

    pozyczki

  • ybivir

    5/15/2017 11:24:09 PM |

    moja strona

  • OEMUM4Uf

    8/28/2017 11:48:24 AM |

    70550 211996We�re glad to become visitor on this pure site, regards in this rare info! 347486

  • arvenholzkissen

    8/28/2017 8:17:34 PM |

    336688 150460What a lovely blog. I�ll surely be back. Please preserve writing! 489342

  • roofing contractor

    8/30/2017 1:40:48 PM |

    501247 97618This is a fantastic web page, could you be interested in performing an interview about just how you designed it? If so e-mail me! 222921

  • Read Full Report

    9/1/2017 11:15:06 PM |

    291842 824029HURRAY! can�t balladeer. by virtue of himself by what name highly. 803868

  • Binomo

    9/4/2017 11:26:49 AM |

    345966 881556hey there i stumbled upon your site searching about the web. I wanted to say I enjoy the look of issues about here. Keep it up will save for confident. 429295

  • http://unover.tv

    9/10/2017 10:12:25 PM |

    182210 932938A thoughtful insight and concepts I will use on my weblog. You�ve obviously spent a great deal of time on this. Thank you! 854955

  • http://constructiongiants.com

    9/11/2017 4:59:02 PM |

    772532 55356I observe there is a lot of spam on this weblog.  Do you need assist cleaning them up?  I may possibly support among classes! 920494

  • Source

    9/11/2017 10:12:07 PM |

    407985 787849Sewing Machines� [...]any time to read or go towards the content material or possibly internet websites we definitely have associated with[...]� 754811

  • dan anton military

    9/13/2017 10:41:36 PM |

    686391 156579Largest lover messages were created to share it along with your and gives honour of the bride and groom. Really sound systems facing unnecessary throngs of people need to take into account each of our valuable concept of all presenting, which is one�s trailer. greatest man toasts 615733

  • 335334 988334Very good post. I previousally to spend alot of my time water skiing and watching sports.  It was quite possible the very best sequence of my past and your content material kind of reminded me of that period of my life.  Cheers 684682

  • teeth implants Boynton Beach

    9/23/2017 10:17:55 PM |

    794107 899395This internet site is actually a walk-through for all of the data you wanted about it and didn�t know who to question. Glimpse here, and you will surely discover it. 350694

  • installment loans for bad credit

    9/24/2017 12:34:56 AM |

    923005 618633This really is a great topic to speak about. Generally when I locate stuff like this I stumble it. This post probably won�t do properly with that crowd. I is going to be confident to submit something else though. 783525

  • see page

    9/25/2017 7:21:43 AM |

    305672 52927Some  truly  good and  utilitarian  information on this  internet site ,  likewise  I think  the  design and style   holds   great  attributes. 285739

  • zdporn.com

    9/25/2017 8:50:46 PM |

    927517 523958All you need to have to know about News details to you. 708952

Loading