ADO.Net result not simple
5 posts
• Page 1 of 1
ADO.Net result not simple
I am using ADO.Net to run some queries and get databack using the
For some columns I get back a vector of
I can convert this to simple APL type using
Is there a better way?
Thanks
2011⌶
For some columns I get back a vector of
B.GetType
System.Int64
I can convert this to simple APL type using
⍎⍕
Is there a better way?
Thanks
- neeraj
- Posts: 82
- Joined: Wed Dec 02, 2009 12:10 am
- Location: Ithaca, NY, USA
Re: ADO.Net result not simple
In case that you have a .net DataTable and you want to convert one column to Apl, this function taken from http://www.AplWiki.com/netDataTable may help you:(link corrected, thanks Kai)
- Code: Select all
apl←dt GetCol colNumber;colName;⎕USING;string;dv
⍝ Get the value of a single column of an existing DataTable
⍝ dt = Data Table
⍝ colNumber = Index of the column (Origin 1)
⍝ apl = Apl data
⍝ Get the name of the column
colName←dt.Columns[colNumber-1].ColumnName
⍝ Create a .net string vector (string[]) with that name
⎕USING←'' 'System.Data,System.Data.dll'
string←System.Array.CreateInstance(System.Type.GetType⊂'System.String')1
string.SetValue(colName 0)
⍝ Make a DataView and filter the method .ToTable
dv←⎕NEW DataView dt
apl←,2011⌶dv.ToTable(0 string)
Last edited by PGilbert on Thu Mar 19, 2015 12:38 pm, edited 1 time in total.
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: ADO.Net result not simple
System.Int64 is not a type whose instances you can represent without loss of precision as native types in Dyalog APL. As long as the integer it wraps is less than 2*53 then you'll be fine. If it's larger then 2*53 (and with an Int64 you have another 11 bits to make your number much bigger) then you won't be fine... Because the trick of executing the formatted version is going to give you a truncated float.
-
StefanoLanzavecchia - Posts: 109
- Joined: Fri Oct 03, 2008 9:37 am
Re: ADO.Net result not simple
Thanks Pierre for all the code on APLWiki. It is so useful to have samples available. Stefano the numbers are small (less than 100), it is the UID field in syslogins table but it comes back as Int64. I anticipate a lossless conversion.
- neeraj
- Posts: 82
- Joined: Wed Dec 02, 2009 12:10 am
- Location: Ithaca, NY, USA
Re: ADO.Net result not simple
The link Pierre's provided should have been http://www.AplWiki.com/netDataTable
-
kai - Posts: 137
- Joined: Thu Jun 18, 2009 5:10 pm
- Location: Hillesheim / Germany
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group