Project Description

QInjection is a library for C# Lambda Query Injection at runtime QInjection.pdf.

QInjection means "Query Injection" and it is a pattern I developed to inject a simple lambda expression on web service side ... but you can also use it in all other situations where you need to apply at runtime a lambda expression on a data collection. (QInjection in 4 images)

QInjection at moment is not a product but a concept, maybe a sort of software mock up, based on
Microsoft Roslyn CTP (Community Technical Preview).



Note: Current release of QInjcetion is focused on simple lambda expressions and complex statementes like Anonymous Function are not recognized.

Sample Code - LPP

ProviderForInjector provider4injector = new ProviderForInjector();
provider4injector.ProvideData();

QInjector injector = new QInjector();

// DEFINE
injector = injector.Support(Node.SimpleLambdaExpression).As(Branch.Input)
            .Support(Node.BinaryExpression).As(Branch.Body)
            .Support(Node.IdentifierName).As(Branch.LeftMember)
            .Support(Node.LiteralExpression).As(Branch.RightMember)
            .Support(Node.Parameter).As(Branch.Parameter);

// VALIDATE
injector.Validate(@"x => x == 1");

// EVALUATE
var genericdata = injector.WhereOn<Int32>(provider4injector);


Sample Code - HPP

ProviderForInjector provider4injector = new ProviderForInjector();
provider4injector.ProvideData();

QInjector injector = new QInjector();

// DEFINE
injector.Begin();
injector = injector.Accept(Element.BinaryExpression).AsBranch();
injector = injector.Accept(Element.UnaryExpression).AsBranch();
injector = injector.Accept(Element.ConditionalExpression).AsBranch();
injector = injector.Accept(Element.IdentifierName).AsBranch();
injector = injector.Accept(Element.LiteralExpression).AsBranch();
injector = injector.Accept(Element.InvocationExpression).AsBranch();
injector = injector.Accept(Element.ParenthesizedExpression).AsBranch();
injector.End();

// VALIDATE
injector.Validate(@"x => x == 1");

// EVALUATE
var genericdata = injector.WhereOn<Int32>(provider4injector);



Sample Code - CPP

ProviderForInjector provider4injector = new ProviderForInjector();
provider4injector.ProvideData();

QInjector injector = new QInjector();

// DEFINE
MyInstructor myinstructor = new MyInstructor();
injector.Teach(MyInstructor);

// VALIDATE
injector.Validate(@"x => x == 1");

// EVALUATE
var genericdata = injector.WhereOn<Int32>(provider4injector);

Last edited Jan 9 at 8:07 PM by SamNium, version 34