Powershell using Linq to SQL to access SQL Server
-
26 Juli 2012 13:58
I'd like to see an example of using Linq to Sql from Powershell. For starters, I just want to do something simple like:
(select foo from bar) | foreach {$_}
Obviously I need some way to specify the server (e.g. 'fum') and database (e.g. 'baz') containing 'bar'
- Diedit oleh Gerald Britton UofT 26 Juli 2012 13:59
- Dipindahkan oleh Bill_StewartMicrosoft Community Contributor 26 Juli 2012 14:34 Move to more appropriate forum (From:The Official Scripting Guys Forum!)
Semua Balasan
-
26 Juli 2012 14:42
Ling is only available in Net 4 and later. PowerShell does not support Net 4.0. Net 4 classes can be used but they need help.
PowerSHell 3 is reported to be Linq friendly. I haven't seen any examples. It could be awsome as it wuld allow us to treat arrays and objects like relational databases.
How about joining two CSVs on a key field and cretain a new table of denormalized data.
Lots of uses with this.
I wonder if anyone else has ever though about this....hmmmm.....
http://bartdesmet.net/blogs/bart/archive/2008/06/07/linq-through-powershell.aspx
¯\_(ツ)_/¯
-
26 Juli 2012 15:06
FWIW I'm using LINQ in Net 3.5. Is it just that Powershell doesn't support LINQ in its curernt version?Ling is only available in Net 4 and later. PowerShell does not support Net 4.0. Net 4 classes can be used but they need help.
PowerSHell 3 is reported to be Linq friendly. I haven't seen any examples. It could be awsome as it wuld allow us to treat arrays and objects like relational databases.
How about joining two CSVs on a key field and cretain a new table of denormalized data.
Lots of uses with this.
I wonder if anyone else has ever though about this....hmmmm.....
http://bartdesmet.net/blogs/bart/archive/2008/06/07/linq-through-powershell.aspx
¯\_(ツ)_/¯
-
26 Juli 2012 15:31
You are correct. It is 3.5. Powershell is set to support 2.0. Any non 2.0 libraries will not load without some adjustment to the PowerShell setup.
Some classes will work but the support is really at the compiler level and not really at the class. What you are asking is if POwerSHell supports Linq as a syntax. I say it will later in V3. or possibley V4. You can still call teh copiler and hand it C# code using Linq. It can be set up as a class. I have not tried it with any of the Linq features yset.
http://msdn.microsoft.com/en-us/library/w4atty68.aspx
¯\_(ツ)_/¯
- Ditandai sebagai Jawaban oleh Gerald Britton UofT 26 Juli 2012 15:57