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

Loading