Differences between revisions 8 and 9
Revision 8 as of 2007-05-10 15:45:19
Size: 3759
Comment:
Revision 9 as of 2007-05-10 15:47:56
Size: 3765
Comment:
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
}}}  }}}
Line 25: Line 26:
}}}
 }}}
Line 31: Line 31:
}}}
 }}}
Line 55: Line 54:
}}}  }}}
Line 78: Line 78:
}}}  }}}
Line 82: Line 82:
CategoryTechnologies CategoryDyalogExamplesDotNet  CategoryTechnologies CategoryDyalogExamplesDotNet

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.


Jasper (last edited 2015-04-05 01:23:20 by PierreGilbert)