Synergi LINQ Provider Prototype

  • .NET/Synergi/LINQ/C#
  • Published: 2014-09-03 06:17:49 +00:00

The last two weeks I have been working on a LINQ provider for Synergi. LINQ is a very nice and useful mechanism for extracting data from any type of data store. When creating a LINQ provider there are some hurdles to overcome. Once you get an understanding of IQueryProvider, IOrderedQueryable<T> and the ExpressionVisitor abstract class, things begin to fall into place.

The following example shows two queries. They both produce the same result, but the last one specifies the entire query using numbers, while the first one uses text representation. When using text representation the text is converted to a number before the search is performed.

SynergiQueryContext ctx = new SynergiQueryContext(ConfigurationInformation.FromAppSettings, new WebServicesParameters("extensive", "extensive",250,2));

           

var query = from c in ctx.QuerySynergi

 where c.ImportDatabaseID == 2

 && c.CaseTypeD == "Audit p%"

 && c.StatusD == "Registered"

 && c.PersonInChargeD == "%extensive%"

 && c.UnitInChargeD == "Unit 0%"

 orderby c.CaseNo ascending

 select c;

foreach (var obj in query)

 MessageBox.Show(obj.ToString());

var query2 = from c in ctx.QuerySynergi

 where c.ImportDatabaseID == 2

 && c.CaseType == 115

 && c.Status == 1

 && c.PersonInCharge == 3

 && c.UnitInCharge == 1

 orderby c.CaseNo ascending

 select c;

foreach (var obj in query2)

 MessageBox.Show(obj.ToString()); 

Both examples produce the same result.

The LINQ provider is not finished yet. There are still a lot more search parameters to add to it, but it is a good example of a LINQ prototype for Synergi.


Comments

Add comment

(no html)
(optional)
(optional)