## Please edit system and help pages ONLY in the moinmaster wiki! For more ## information, please see MoinMaster:MoinPagesEditorGroup. ##master-page:HelpTemplate ##master-date:Unknown-Date #format wiki #language en == Microsoft's Project Jasper == Currently an incubation project of the Data Access and Storage section at Microsoft, Jasper is a set of .NET classes "geared towards interative and agile development". For the download links check: http://msdn2.microsoft.com/en-us/data/bb419139.aspx The idea behind the project is to have the runtime generate all the data access classes without the need for the developer to write them manually. In fact it's easier to show a sample, in our beloved Dyalog 11 than to read the documentation. I translated the sample from the example in Python (which is a lovely language, easy to read and understand). In order to iterate through the collections returned by the various methods, let's first define a sample operator ''foreach''. {{{ r←(fn foreach)coll;x r←⍬ :For x :In coll r,←⊂fn x :EndFor }}} MortenKromberg suggest an alternative coding for the operator ''foreach'' based on the semantics of the monadic ''squad'': {{{ foreach←{⍺⍺¨⌷⍵} }}} ''conn'' is the connection string: {{{ Provider='System.Data.SqlClient';Provider Connection String='Data Source=.\SQLExpress;Initial Catalog=Northwind;Integrated Security=True;';Generate Default EDM=True; }}} Now, the test function. {{{ test;⎕USING;ctx;cust;custQuery;orderQuery ⎕USING←'' 'Microsoft.Jasper,C:\Programmi\Microsoft Codename Jasper CTP\Binaries\Microsoft.Jasper.CTP.dll' ctx←DynamicContext.CreateDynamicContext⊂conn ⍝ direct access ⎕←{⍵.CategoryName}foreach ctx.Categories ⍝ simple query ⎕←↑{⍵.(ProductName UnitPrice)}foreach ctx.Products.Where'it.ProductName = ''Chai'''⍬ ⍝ find by key cust←ctx.Customers.FindByKey⊂,⊂'AROUT' ⎕←cust.(CustomerID CompanyName) ⍝ composite query custQuery←ctx.Customers custQuery←custQuery.Where'it.Country = ''USA'''⍬ custQuery←custQuery.OrderBy'it.CompanyName'⍬ custQuery←custQuery.Select'it.CustomerID, it.CompanyName, it.City'⍬ ⎕←↑{⍵.(CustomerID CompanyName City)}foreach custQuery ⍝ relationship navigation in query orderQuery←ctx.Orders.Where'it.Customer.CompanyName = ''Around the Horn'''⍬ ⎕←↑{⍵.(OrderID OrderDate)}foreach orderQuery }}} Here's an alternative coding of this test script, based on the simplification offered by Morten's ''foreach'': {{{ test1;⎕USING;ctx;cust;custQuery;orderQuery ⎕USING←'' 'Microsoft.Jasper,C:\Programmi\Microsoft Codename Jasper CTP\Binaries\Microsoft.Jasper.CTP.dll' ctx←DynamicContext.CreateDynamicContext⊂conn ⍝ direct access ⎕←(⌷ctx.Categories).CategoryName ⍝ simple query ⎕←↑(⌷ctx.Products.Where'it.ProductName = ''Chai'''⍬).(ProductName UnitPrice) ⍝ find by key cust←ctx.Customers.FindByKey⊂,⊂'AROUT' ⎕←cust.(CustomerID CompanyName) ⍝ composite query custQuery←ctx.Customers custQuery←custQuery.Where'it.Country = ''USA'''⍬ custQuery←custQuery.OrderBy'it.CompanyName'⍬ custQuery←custQuery.Select'it.CustomerID, it.CompanyName, it.City'⍬ ⎕←↑(⌷custQuery).(CustomerID CompanyName City) ⍝ relationship navigation in query orderQuery←ctx.Orders.Where'it.Customer.CompanyName = ''Around the Horn'''⍬ ⎕←↑(⌷orderQuery).(OrderID OrderDate) }}} Easier than writing SQL queries and no need to write any other code except what I listed here. I am amazed. ---- CategoryTechnologies - CategoryDotNet - CategoryDyalogDotNet - CategoryDyalogExamplesDotNet