The origin of QInjection

QInjection stays for Query Injection and it is a pattern I developed to inject simple lambda expression on web service interface.
QInjection at moment is not a product but a concept, maybe a software mock up, based on Roslyn CTP (Community Technical Preview)
You can find it at codeplex ath this URL.

I develepod it in order to implement a pattern like "Filter Data at Service Side by Supplying your Lambda Query". Let me to explain with an example.

Suppose you have the following web service operation:

IEnumerable<int> GetData();


Suppose you want to filter the collection using a simple lambda criteria as "x => x == 1".

Usually you istantiate the web service proxy, the client, and you write code like this:

var data = client.GetData
var filteredData = data.Where(x => x == 1).ToList();


Following picture illustrate the pattern you used: data are collected at web service side, then returned by the operation and then filtered with the query at client side.



If the array include only the 10% of 1 values then you use the 90% of the network bandwidth to transfer "garbage".
Moreover if the array includes many elements then you have also to consume more CPU and memory also at the client side (you should need big wcf buffers and you need to spent more time to analyze data gathered).

Now, suppose to pass the query "x => x == 1" as parameter of the web operation and to filter the data at service side.
In this case you will have some benefits: only the 10% of the data will be transferred, wcf buffer can be better adapted at your needs, you don't need to analyze the data a new time.

Following picture illustrate this kind of implementation..



Then, the goals of QInjection was this: allow you to implement a web operation as the following one:

IEnumerable<int> SSWhere(String Expression);


where SSWhere stays for Service Side Where.

The client code becames:

var data = client.SSWhere("x => x == 1");


The main challange is about how to manage the lambda expression that is transferred as String from the client to the server; and the web service needs to interpretate, validate and execute the expression.

This is the job made by QInjection, and it is made using Roslyn.
Maybe on the web there are components that already make this kind of jobs ... but I implemented it using Roslyn ... and my personal goal was to learn Roslyn and to apply it on a real problem.

I'll come back soon.

Last edited Jan 1, 2014 at 4:52 PM by SamNium, version 12