Multiple Item support for same property in where clause : LinqExtender

Just a few days ago I have rolled up another patch for LinqExtender which is 1.3.2 , this is reported to me from a work item, especially to support the following query

var query = from book in _context.Books
            where book.PublishedDate > someDate 
            and book.PublishedDate < someDate
            select book;

Here we can see that there are similar property is used for different segment in where clause. Now, previously this kind of query used to fail tests as bucket.Items["SomeProperty"].Value and bucket.Items["SomeProperty"].RelationType only returns single item value and relation type respectively. Therefore, I have added a new property that will be used to handle multiple homogenous query conditions and which can be used  like the following

IList<BucketItem.QueryCondition> conditions  = bucket.Items["SomeProperty"].Values

foreach (BucketItem.QueryCondtion condition in conditions)
{
  // do something precious with the value.
  obj value =  condition.Value;
  // contains less, equal, etc.
  RelationType rel = condtion.RelationType; 
}

In case, your data source don't have that capability for doing this kind of query , and you decide to stick to the single item getter, then the provider will gracefully give "not supported" exception rather than quietly failing the unit test :-). Again, its up to the user how they use it and hope it comes handy.

kick it on DotNetKicks.com

No Comments