Search by Text in combination w/ AND, OR or NOT

Perform text searches using operands and operators together. When no operator is supplied between words ‘AND’ is default.

   1:  _entities = new NorthwindEntities();
   2:  var customers = _entities.Search<Customer>("john and aria michael OR yang not steel MEXICO");

Search using PHRASES

Additionally to working with operators and operands, you may use phrases by providing double quotes “around sets of words”.

   1:  customers = _entities.Search<Customer>(@"owner AND Ana Sales ""Aria Cruz""");

Search by WHERE clause

Provide a Func<T, bool> delegate to reduce the size of the search.

   1:  customers = _entities.Search<Customer>("john michael OR yang",                                       
   2:                                         (Customer c) => c.ContactTitle == "owner");

Search by TYPE clause

Provide a Func<Type, bool> delegate to specify the types on the  EF object being searched. Supply default(Func<Type,bool>) as null.

   1:   customers = _entities.Search<Customer>(@"owner AND Ana Sales ""Aria Cruz""",
   2:                                          (Customer c) => c.Address != string.Empty,
   3:                                          (Type t) => t == typeof(string) || t == typeof(int));

Search by PropertyInfo clause

Provide a Func<PropertyInfo, bool> delegate to access properties of Entity Framework object being searched. Supply default(Func<PropertyInfo,bool>) as null.

   1:   customers = _entities.Search<Customer>(@"owner AND Ana Sales ""Aria Cruz""",
   2:                                          (Customer c) => c.Address != string.Empty,
   3:                                          (PropertyInfo p) => p.Name == “ContactName” || p.Name == “ContactTitle”);

Perform a search and a JOIN in the same LINQ statement

Do an advanced search using SearchEF and standard LINQ implementation models. The Search<T> method returns a List<ISearchResult<T>>  where T is the EntityObject type.

   1:  var orders = (from customer in _entities.Search<Customer>(@"owner AND Ana Sales ""Aria Cruz""",
   2:                                                                     (Customer c) => c.Address != string.Empty,
   3:                                                                     (Type t) => t == typeof(string) || t == typeof(int))
   4:                join order in _entities.Search<Order>("mexico NOT canada")
   5:                on customer.Value.CustomerID equals order.Value.CustomerID
   6:                select order).ToList();

Last edited May 19, 2011 at 11:18 PM by jlevingston, version 14

Comments

No comments yet.