![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - can I do inner queries? or joins? |
| |
| 09-03-2007 | #1 |
| | can I do inner queries? or joins? not sure that inner queries or joins are really the right name for what I'm trying to do... I have a Get-MyObject cmdlet that returns me a number of objects - .net objects. By default, all of the different properties are dumped to the console as expected. One of the properties of my object is a handle to another object. This property is printed out as it's class type. What I want to do is access properties of the object that is referred to in that property. E.g. if I had objects which contained properties like this: MyObject -> Name (string) -> Id (int) -> MyFriend (MyOtherObject) -> etc. MyOtherObject -> Name (string) -> Id (int) -> SomethingElse (string) -> etc. I want to be able to do something like: Get-MyObject * | Select Name, Id, MyFriend.Name Is this possible? Is it just a syntax issue, or is there more to it? D PS - Sincerest apologies for the incoherent rambling attempt to explain what I'm doing in an abstract way :-) |
| My System Specs |
| 09-03-2007 | #2 |
| | Re: can I do inner queries? or joins? "dale" <dale@xxxxxx> wrote in message news:7F89E608-298B-48D4-BCE9-4C3ED8C35CC5@xxxxxx Quote: > not sure that inner queries or joins are really the right name for what > I'm > trying to do... > > I have a Get-MyObject cmdlet that returns me a number of objects - .net > objects. By default, all of the different properties are dumped to the > console as expected. > > One of the properties of my object is a handle to another object. This > property is printed out as it's class type. > > What I want to do is access properties of the object that is referred to > in > that property. > > E.g. if I had objects which contained properties like this: > > MyObject > -> Name (string) > -> Id (int) > -> MyFriend (MyOtherObject) > -> etc. > > MyOtherObject > -> Name (string) > -> Id (int) > -> SomethingElse (string) > -> etc. > > I want to be able to do something like: > > Get-MyObject * | Select Name, Id, MyFriend.Name > Get-MyObject * | select Name, Id, @{e={$_.MyFriend.Name};n='MyFriendsName'} It is not really a join. However you create a hashtable that tells the select cmdlet what expression (e) to project into the PSCustomObject that it creates. You can optionally give that new item a name (n). -- Keith |
| My System Specs |
| 09-03-2007 | #3 |
| | Re: can I do inner queries? or joins? That worked - many thanks! D "Keith Hill" wrote: Quote: > "dale" <dale@xxxxxx> wrote in message > news:7F89E608-298B-48D4-BCE9-4C3ED8C35CC5@xxxxxx Quote: > > not sure that inner queries or joins are really the right name for what > > I'm > > trying to do... > > > > I have a Get-MyObject cmdlet that returns me a number of objects - .net > > objects. By default, all of the different properties are dumped to the > > console as expected. > > > > One of the properties of my object is a handle to another object. This > > property is printed out as it's class type. > > > > What I want to do is access properties of the object that is referred to > > in > > that property. > > > > E.g. if I had objects which contained properties like this: > > > > MyObject > > -> Name (string) > > -> Id (int) > > -> MyFriend (MyOtherObject) > > -> etc. > > > > MyOtherObject > > -> Name (string) > > -> Id (int) > > -> SomethingElse (string) > > -> etc. > > > > I want to be able to do something like: > > > > Get-MyObject * | Select Name, Id, MyFriend.Name > > > Try this: > > Get-MyObject * | select Name, Id, @{e={$_.MyFriend.Name};n='MyFriendsName'} > > It is not really a join. However you create a hashtable that tells the > select cmdlet what expression (e) to project into the PSCustomObject that it > creates. You can optionally give that new item a name (n). > > -- > Keith > |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: can I do inner queries? or joins? | ||||
| Thread | Forum | |||
| Vista upgrade joins domain, won't connect | SBS Server | |||
| Vista upgrade joins domain, won't connect | SBS Server | |||
| U.S. Government Joins Microsoft Against States | General Discussion | |||
| Sorry Frankie Boy - Microsoft joins Open Source | Vista General | |||
| Mandrive joins Ubuntu and Red Hat | Vista General | |||