LinqExtender 1.2 is out now

Since, the first release of LinqExtender, I found quite a bit download and feedback from community around. I did plenty of changes and tried to make it as simple as possible for  creating custom providers  without knowing a bit of reflection and expression parsing of the core framework.

After the release , I was asked by people around that why do we need LINQ when we can do it by method calls. The answer to it is, LINQ  gives another level of abstraction to method call that enables you to set a query domain for developers, by means of strongly type query objects, it's not like exposing the data access layer to the front end developer, but it is like giving them a playground with proper boundary. In other words, front end developers now can query on some specific criteria  that we set by means of query object , still giving them a flexibility of functional programming.

Now on to the release 1.2. it has come with query info retrieval wrapper and some new features ,which could be useful while making custom providers.

I have mentioned in following post, how query data is delegated to Process routine, that will be overridden in the custom provider that developer is working on.

http://weblogs.asp.net/mehfuzh/archive/2007/12/02/linqextender.aspx

Now with new release it looks something like

protected override void Process(LinqExtender.Interface.IModify<T> items, Bucket bucket)

As , you can see that it has Bucket object, which is nothing but a wrapper for holding the query details. Each Bucket has some BucketItem. BucketItem contains info for each property used in the expression  separated by &&.

Typically BucketItem looks like

BucketItem
Name
- Property name, different if the used with OriginalFieldNameAttribute, or less it is same as property name.
Value - value in the query , for which the property is compared. Default value, Null.
Unique - True , if UniqueIdentifierAttribute or its inherited type is used on property.Here, one can Use UniqueIdentifierAttribute directly on property or can use any inherited form like, PrimaryKeyAttribute that inherits the UniqueIdentifierattribute, to reflect value to this property.
RelationType : Enum - Equal , LessThan, LessThatEqual, GreaterThan, GreaterThanEqual. Used to identify which type of logical comparison is used.

Any of the property, which is not used in a query , BucketItem.Value and BucketItem.RelationType will have the default value for it, which is Null and Equal respectively.

Now, Going Back to Bucket it looks like

Bucket
IDictionary<string, BucketItem> Items - List of items for property,  where string is the property name of the query object, BuckItem represents how the Property is treated and used in query.
ItemsToTake - default null , if Take is not specified in query.
ItemsToTake - default 0, if Skip is not specified in query.
UniqueItems - string[], contains the name of property on which UniqueIdentifierAttribute or its derivative is applied.

As, we can see from this release that Linqextender supports most common logical expression rather than just Equal expression.

The new release also supports  "New Type" queries, which i already mentioned in this post

http://weblogs.asp.net/mehfuzh/archive/2007/12/16/anonymous-type-in-linqextender.aspx

Finally, I have added CTE(Common table expression) generation for OpenLinqToSql (Formerly known as TinyLinqToSql) provider.

Now , queries like the following with Take and Skip

SqlQuery<Book> context = new SqlQuery<Book>();
var query = (from q in _queryContext
             orderby q.LastUpdated ascending
             select q).Take(5).Skip(2);
// this is where the query will execute
foreach(var book in query)
{
 // do something useful 
}

Will generate Sql like...

WITH FilteredList(Id,Author,Title,ISBN,LastUpdated, [RowNumber]) AS(
SELECT Id,Author,Title,ISBN,LastUpdated, Row_number()OVER(ORDER BY 
LastUpdated asc) as [RowNumber] FROM Book 
)Select * from FilteredList WHERE [Rownumber] Between (3) and (7)

Here, Take(5), Skip(2), it will take 5 items starting from 3.

For more, I would suggest to have a look at release page of LinqExtender

OpenLinqToSql provider is made to exercise the LinqExtender engine , it is provided with the LinqExtender source and with NUnit test class in LinqExtender project itself. There is another project named Linq.Flickr, where I have originally started working on with Linq provider and then made LinqExtender, this is currently a separate project. This shows another  possible implementation of LinqExtender for service end points.

Happy Holidays!!!

kick it on DotNetKicks.com

No Comments