Mehfuz's WebLog

Live crazy, think different!

Sponsors

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

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# April 5, 2008 2:51 AM

LINQ Recipes said:

Multiple Item support for same property in where clause : LinqExtender

# April 7, 2008 10:11 AM

Multiple Item support for same property in where clause : LinqExtender said:

Pingback from  Multiple Item support for same property in where clause : LinqExtender

# April 26, 2008 4:19 PM

Multiple Item support for same property in where clause : LinqExtender said:

Pingback from  Multiple Item support for same property in where clause : LinqExtender

# April 27, 2008 3:26 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)