<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jakub@Work</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jakuboleksy/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/feed.xml</link>
    <description>Programming with System Center Service Manager and Operations Manager</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:10:21 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>New Blog</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/new-blog</link>
      <pubDate>Wed, 02 Jun 2010 15:18:16 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2010/06/02/new-blog/</guid>
      <description><![CDATA[We've started up a new blog dedicated to the Service Manager Platform...]]></description>
      <content:encoded><![CDATA[<p>We've started up a new blog dedicated to the Service Manager Platform (<a href="https://blogs.msdn.com/b/scplat/">https://blogs.msdn.com/b/scplat/</a>). New posts will be going there and I will stop posting new content here, although I'll leave the current content up for reference.</p>]]></content:encoded>
    </item>
    <item>
      <title>Getting Closer</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/getting-closer</link>
      <pubDate>Thu, 04 Feb 2010 12:50:36 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2010/02/04/getting-closer/</guid>
      <description><![CDATA[We’re pushing hard as a team to finish up Service Manager and we’re getting closer :-). I apologize...]]></description>
      <content:encoded><![CDATA[<p>We’re pushing hard as a team to finish up Service Manager and we’re getting closer :-). I apologize for not having any content related posts in quite some time. I’ve still been fielding questions sent directly to me and please keep them coming. </p>  <p>As folks start using the Service Manager platform, I hope to have more relevant content to post for folks to help. Also, the Service Manager team blog is very active going over various features of the products and customizations and extensions that are possible. </p>]]></content:encoded>
    </item>
    <item>
      <title>Service Manager 2010 Beta 2 Released</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/service-manager-2010-beta-2-released</link>
      <pubDate>Mon, 05 Oct 2009 19:32:24 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/10/05/service-manager-2010-beta-2-released/</guid>
      <description><![CDATA[We released our public Beta 2 on Friday and are busy making progress toward our RTM early next year....]]></description>
      <content:encoded><![CDATA[<p>We released our public Beta 2 on Friday and are busy making progress toward our RTM early next year. This is a fully public, feature complete Beta available on the Microsoft Connect site. The email sent from the Connect site to subscribers:</p>  <p>The Service Manager team is very pleased to announce that Beta-2 for Service Manager 2010 is now available for download from connect. Details and links are below. </p>  <p><strong>Download</strong></p>  <p>To download, simply go to the Service Manager site on Connect <a href="https://www.connect.microsoft.com/">www.connect.microsoft.com</a>. Once you have successfully signed in, click the Downloads link, click <strong>Service Manager Beta-2 </strong>and then select all of the following files on the download details page: </p>  <p>· SMCDImage_amd64.exe</p>  <p>· SMCDImage_x86.exe (32 bit console)</p>  <p>· InstallOMMPs.exe </p>  <p>· AuthoringTool.exe (authoring console)</p>  <p>· SM_B2_Public.zip</p>  <p>Click <strong>download</strong> to begin the download process. Once the files have successfully downloaded, please be sure to read the release notes before installing the product as they contain some important information about the release</p>  <p>You can also use the public forums for feedback and support, link below   <br /><a href="https://forums.microsoft.com/TechNet/ShowForum.aspx?ForumID=2066&amp;SiteID=17">https://forums.microsoft.com/TechNet/ShowForum.aspx?ForumID=2066&amp;SiteID=17     <br /></a>    <br />Please read the “Preparing for Service Manager Deployment” section of the <strong>Installation and Configuration </strong>Guide for step-by-step guidance on how to install and configure the product.</p>]]></content:encoded>
    </item>
    <item>
      <title>Object Templates</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/object-templates</link>
      <pubDate>Fri, 26 Jun 2009 16:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/06/26/object-templates/</guid>
      <description><![CDATA[In Service Manager, we have a variety of scenarios where we needed to capture partial object state...]]></description>
      <content:encoded><![CDATA[<p>In Service Manager, we have a variety of scenarios where we needed to capture partial object state and apply that state at a later time. The state captured is usually all or part of some IT process. For example, when creating a Change Request from the UI, the user is prompted with a set of templates to choose from, each representing a different kind of change request. These templates are stored as Object Templates in MPs and pre-define a set of values to populate the change request form with. </p>  <p>Object templates can be used to store data about classes as well as projections. They are neither classes, nor objects, but rather blueprints (stored in management packs) for creating or modifying objects. In the attached MP you will find three different object templates. </p>  <div style="padding-bottom: 5px; padding-left: 5px; width: 1031px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4c58ac8c-6b15-469c-bfb7-edd022ce5fb2" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0">
<ol style="background: #ffffff; margin: 0 0 0 25px; white-space: wrap">
<li> <span style="color:#0000ff">    &lt;</span><span style="color:#a31515">ObjectTemplate</span><span style="color:#0000ff"> </span><span style="color:#ff0000">ID</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">NFL.NFCDivision.Template</span>"<span style="color:#0000ff"> </span><span style="color:#ff0000">TypeID</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">NFL.Division</span>"<span style="color:#0000ff"> &gt;</li><li style="background: #f3f3f3">       &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Conference']/Name$</span>"<span style="color:#0000ff">&gt;</span>NFC<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li>     &lt;/</span><span style="color:#a31515">ObjectTemplate</span><span style="color:#0000ff">&gt;</span></li>
</ol>
</div>
</div>
</div>  <p>The first two set properties of a class. The Path notation is the same as used in projections, with the exception that you specify the particular property you want to set as well. You can specify as many or as few properties as you want, these objects don’t need to be complete, but we do verification to ensure property values make sense. </p>  <p>Projections can also be defined:</p>  <div style="padding-bottom: 5px; padding-left: 5px; width: 1031px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f209e67-d4ff-4f6f-8862-7b01a1fc5705" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0">
<ol style="background: #ffffff; margin: 0 0 0 35px; white-space: wrap">
<li> <span style="color:#0000ff">    &lt;</span><span style="color:#a31515">ObjectTemplate</span><span style="color:#0000ff"> </span><span style="color:#ff0000">ID</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">NFL.New.Template</span>"<span style="color:#0000ff"> </span><span style="color:#ff0000">TypeID</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">NFL.Conference.All</span>"<span style="color:#0000ff"> &gt;</li><li style="background: #f3f3f3">       &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Conference']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Conference<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li>       &lt;</span><span style="color:#a31515">Object</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Path[Relationship='NFL.ConferenceHostsDivision']$</span>"<span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">         &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Conference']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Conference<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li>         &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Division']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Division 1<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">         &lt;</span><span style="color:#a31515">Object</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Path[Relationship='NFL.DivisionContainsTeam' TypeConstraint='NFC.Team']$</span>"<span style="color:#0000ff">&gt;</li><li>           &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFC.Team']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Team<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">         &lt;/</span><span style="color:#a31515">Object</span><span style="color:#0000ff">&gt;</li><li>       &lt;/</span><span style="color:#a31515">Object</span><span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">       &lt;</span><span style="color:#a31515">Object</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Path[Relationship='NFL.ConferenceHostsDivision']$</span>"<span style="color:#0000ff">&gt;</li><li>         &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Conference']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Conference<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">         &lt;</span><span style="color:#a31515">Property</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Path</span><span style="color:#0000ff">=</span>"<span style="color:#0000ff">$Target/Property[Type='NFL.Division']/Name$</span>"<span style="color:#0000ff">&gt;</span>New Division 2<span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Property</span><span style="color:#0000ff">&gt;</li><li>       &lt;/</span><span style="color:#a31515">Object</span><span style="color:#0000ff">&gt;</li><li style="background: #f3f3f3">     &lt;/</span><span style="color:#a31515">ObjectTemplate</span><span style="color:#0000ff">&gt;</span></li>
</ol>
</div>
</div>
</div>  <p>   <br />These are similar, but allow you to define a hierarchy of objects that conform to the projection definition the object template references. Whenever you want to define a new object, you need to ensure the endpoint of the relationship is concrete, or you need to specify the TypeConstraint to indicate what class you want to create, as in the example above. </p>  <p>In code, you can use these templates to create new objects or update existing objects:</p>  <div style="padding-bottom: 5px; padding-left: 5px; width: 1031px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:270fc182-8d05-4f63-abbb-b4a51a116e05" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0">
<ol style="background: #ffffff; margin: 0 0 0 35px; white-space: wrap">
<li>             <span style="color:#008000">// Connect to the management group</span></li><li style="background: #f3f3f3">             <span style="color:#2b91af">EnterpriseManagementGroup</span> managementGroup =</li><li>                 <span style="color:#0000ff">new</span> <span style="color:#2b91af">EnterpriseManagementGroup</span>(<span style="color:#a31515">"localhost"</span>);</li><li style="background: #f3f3f3"> </li><li>             <span style="color:#008000">// Get the management pack</span></li><li style="background: #f3f3f3">             <span style="color:#2b91af">ManagementPack</span> nflManagementPack = </li><li>                 managementGroup.ManagementPacks.GetManagementPack(<span style="color:#a31515">"NFL"</span>, <span style="color:#0000ff">null</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Version</span>(<span style="color:#a31515">"1.0.0.0"</span>));</li><li style="background: #f3f3f3"> </li><li>             <span style="color:#008000">// Get the object templates</span></li><li style="background: #f3f3f3">             <span style="color:#2b91af">ManagementPackObjectTemplate</span> nfcDivisionTemplate = </li><li>                 nflManagementPack.GetObjectTemplate(<span style="color:#a31515">"NFL.NFCDivision.Template"</span>);</li><li style="background: #f3f3f3">             <span style="color:#2b91af">ManagementPackObjectTemplate</span> afcDivisionTemplate = </li><li>                 nflManagementPack.GetObjectTemplate(<span style="color:#a31515">"NFL.AFCDivision.Template"</span>);</li><li style="background: #f3f3f3">             <span style="color:#2b91af">ManagementPackObjectTemplate</span> nflTemplate = </li><li>                 nflManagementPack.GetObjectTemplate(<span style="color:#a31515">"NFL.New.Template"</span>);</li><li style="background: #f3f3f3"> </li><li>             <span style="color:#008000">// Create a new NFC division using the template</span></li><li style="background: #f3f3f3">             <span style="color:#2b91af">CreatableEnterpriseManagementObject</span> newNfcDivision = </li><li>                 <span style="color:#0000ff">new</span> <span style="color:#2b91af">CreatableEnterpriseManagementObject</span>(managementGroup, nfcDivisionTemplate);</li><li style="background: #f3f3f3"> </li><li>             <span style="color:#008000">// Change it to an AFC division</span></li><li style="background: #f3f3f3">             newNfcDivision.ApplyTemplate(afcDivisionTemplate);</li><li> </li><li style="background: #f3f3f3">             <span style="color:#008000">// Create a new projection from a template</span></li><li>             <span style="color:#2b91af">EnterpriseManagementObjectProjection</span> newNfl = </li><li style="background: #f3f3f3">                 <span style="color:#0000ff">new</span> <span style="color:#2b91af">EnterpriseManagementObjectProjection</span>(managementGroup, nflTemplate);</li><li> </li><li style="background: #f3f3f3">             <span style="color:#008000">// You can also apply a template to an existing projection</span></li><li>             newNfl.ApplyTemplate(nflTemplate);</li><li style="background: #f3f3f3"> </li>
</ol>
</div>
</div>
</div>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/80/59/54/NFL.xml" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-80-59-54/NFL.xml">NFL.xml</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Categorizing Management Pack Elements</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/categorizing-management-pack-elements</link>
      <pubDate>Wed, 03 Jun 2009 11:49:00 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/06/03/categorizing-management-pack-elements/</guid>
      <description><![CDATA[If you are familiar with Management Packs and their elements in Operations Manager, you'll know that...]]></description>
      <content:encoded><![CDATA[<P>If you are familiar with Management Packs and their elements in Operations Manager, you'll know that there were a few elements that had a "Category" attribute whose value was fixed from an enumeration defined in the schema. While this worked, it was quite limiting. For one, the enumeration itself did not make a lot of sense globally. There were values in the enumeration that only applied to some of the elements that used it. Next, it only allowed for some elements to be categorized and only once. Finally, the enumeration was not extensible. </P>
<P>In Service Manager we've added the ability to categorize any Management Pack element via an extensible mechanism that leverages the new concept of enumerations as defined in management packs. Enumerations are essentially hierarchal extensible lists that are defined in management packs. They can be used both as values for class properties as well as values for categorization of elements. In this article, I'll be discussing the latter. </P>
<P>I've updated the NFL management pack I have been using and introduced a new enumeration and some categories. First, you'll find the following enumeration defined:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>EnumerationTypes</SPAN><SPAN class=kwrd>&gt;</SPAN>
        <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>EnumerationValue</SPAN> <SPAN class=attr>ID</SPAN><SPAN class=kwrd>="NFL.VisibleToCallers"</SPAN> <SPAN class=attr>Accessibility</SPAN><SPAN class=kwrd>="Public"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>EnumerationTypes</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>I can define enumerations to mean just about anything I want as the consumer of these enumerations and subsequent categories defines their behavior. In this case, I am defining an enumeration that categorizes elements as visible to callers via some API that I will be providing.</P>
<P>Once I have defined my enumeration, the next step is to categorize my elements as "in" the value. For this, I need to define category elements:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Categories</SPAN><SPAN class=kwrd>&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Category</SPAN> <SPAN class=attr>ID</SPAN><SPAN class=kwrd>="NFL.Visibility1"</SPAN> <SPAN class=attr>Target</SPAN><SPAN class=kwrd>="NFL.Conference"</SPAN> <SPAN class=attr>Value</SPAN><SPAN class=kwrd>="NFL.VisibleToCallers"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Category</SPAN> <SPAN class=attr>ID</SPAN><SPAN class=kwrd>="NFL.Visibility2"</SPAN> <SPAN class=attr>Target</SPAN><SPAN class=kwrd>="NFL.Division"</SPAN> <SPAN class=attr>Value</SPAN><SPAN class=kwrd>="NFL.VisibleToCallers"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Category</SPAN> <SPAN class=attr>ID</SPAN><SPAN class=kwrd>="NFL.Visibility3"</SPAN> <SPAN class=attr>Target</SPAN><SPAN class=kwrd>="NFL.Team"</SPAN> <SPAN class=attr>Value</SPAN><SPAN class=kwrd>="NFL.VisibleToCallers"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>Categories</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>As you can see, I've placed three classes into my enumeration, thus categorizing them. But what does this mean from an API perspective? Really, it doesn't mean anything unless the consumer honors the categorization. As an example, the Service Manager UI uses various enumerations as defined in our management packs to categorize elements, such as console tasks or views, to control their visibility behavior in the UI. </P>
<P>Next, I'll demonstrate how a caller of the API can use this categorization. In the following sample, after importing the attached management pack, I retrieve the defined enumeration and generate criteria from it to filter out the classes I want to retrieve based on the categorization:</P><PRE class=csharpcode>            <SPAN class=rem>// Connect to the management group</SPAN>
            EnterpriseManagementGroup managementGroup =
                <SPAN class=kwrd>new</SPAN> EnterpriseManagementGroup(<SPAN class=str>"localhost"</SPAN>);

            <SPAN class=rem>// Get the management pack</SPAN>
            ManagementPack nflManagementPack = 
                managementGroup.ManagementPacks.GetManagementPack(<SPAN class=str>"NFL"</SPAN>, <SPAN class=kwrd>null</SPAN>, <SPAN class=kwrd>new</SPAN> Version(<SPAN class=str>"1.0.0.0"</SPAN>));

            <SPAN class=rem>// Get the type enumeration value</SPAN>
            ManagementPackEnumeration showToCallersEnumeration =
                nflManagementPack.GetEnumeration(<SPAN class=str>"NFL.VisibleToCallers"</SPAN>);

            <SPAN class=rem>// Create an in statement using the category property</SPAN>
            <SPAN class=kwrd>string</SPAN> classCriteria = <SPAN class=kwrd>string</SPAN>.Format(<SPAN class=str>@"&lt;Criteria xmlns="</SPAN><SPAN class=str>"https://Microsoft.EnterpriseManagement.Core.Criteria/"</SPAN><SPAN class=str>"&gt;
                                        &lt;Expression&gt;
                                            &lt;In&gt;
                                              &lt;GenericProperty&gt;Category&lt;/GenericProperty&gt;
                                              &lt;Values&gt;
                                                &lt;Value&gt;{0}&lt;/Value&gt;
                                              &lt;/Values&gt;
                                            &lt;/In&gt;
                                          &lt;/Expression&gt;
                                        &lt;/Criteria&gt;"</SPAN>, showToCallersEnumeration.Id);

            <SPAN class=rem>// Create the criteria object</SPAN>
            ManagementPackClassCriteria classesVisibleToCallersCriteria = <SPAN class=kwrd>new</SPAN> ManagementPackClassCriteria(classCriteria);
            
            <SPAN class=rem>// Get classes using criteria</SPAN>
            IList&lt;ManagementPackClass&gt; classesVisibleToCallers = managementGroup.EntityTypes.GetClasses(classesVisibleToCallersCriteria);</PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P><STRONG>Important Note: </STRONG>The criteria behaves in the following way with respect to inclusion and exclusion of categories. If you generate a query as shown earlier, it will return any class that is in this category, regardless if it is in other categories. If you change the query to ask for classes where category is not of a particular id, it will exclude the classes that are ONLY in that particular category; so if a class is in category A and B and you ask for classes not in B, you will still get the class back because A is not in B. If a class is only in category B and you ask for classes not in B, you will not get it back because that class is exclusively in B and thus NOT IN B is false. Even if this didn't make sense to you (I had to read it back several times myself :-) ), essentially what this means is that NOT EQUAL to a particular category queries just don't work the way you would expect so please don't use them or understand how they work before you do. To mitigate this problem, we are planning on caching categories client-side so users can quickly do filtering post-query for "NOT" semantics. </P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/69/16/22/NFL.xml" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-69-16-22/NFL.xml">NFL.xml</a></p>]]></content:encoded>
    </item>
    <item>
      <title>New Criteria</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/new-criteria</link>
      <pubDate>Wed, 06 May 2009 19:55:53 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/05/06/new-criteria/</guid>
      <description><![CDATA[Well, we're back from MMS which was pretty successful for Service Manager in general. In a lot of...]]></description>
      <content:encoded><![CDATA[<p>Well, we're back from MMS which was pretty successful for Service Manager in general. In a lot of ways, it was a coming out party of sorts as we were able to demonstrate a ton of functionality about the product and really show how well it is coming along. My session with Travis went great and I really feel we did a solid job in speaking to and demonstrating the power of the Service Manager platform. The team is heads down in Beta 2 right now as we push for an early Fall release. Beta 2 is very exciting for us because at that point the product is basically complete from a feature perspective and customers will be able to play with as close to the final bits as they've ever had. I really hope we get a lot more people interested in customization and extension at that time and I'll be excited to blog about a lot of the new features we're introducing in Beta 2 from an SDK perspective.</p>  <p>In this post, I wanted to talk about our new criteria a little bit and introduce you to the new format and some of the new concepts. If you are familiar with OM, the criteria there was very similar to a WHERE clause in SQL. While this was very friendly from an end-user perspective, it actually was quite burdensome from a developer perspective, both in generating complicated criteria and for us in parsing it and ensuring its uniqueness. For Service Manager 2010 we decided to prioritize power and ease of programmatic manipulation over readability and the ability to quickly script the criteria. Criteria is used in for querying for a variety of objects in the SDK. Here's I'll use examples mostly around the instance and projection space. </p>  <p><strong><em>Simple Expression       <br /></em></strong>A simple expression just compares a property to a value. In this example we are comparing PropertyName on ClassName to the value 3. </p>  <pre class="csharpcode">               <span class="kwrd">&lt;</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Property</span><span class="kwrd">&gt;</span>$Target/Property[Type='ClassName']/PropertyName$<span class="kwrd">&lt;/</span><span class="html">Property</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">Operator</span><span class="kwrd">&gt;</span>Equal<span class="kwrd">&lt;/</span><span class="html">Operator</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>3<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;/</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style></pre>

<p>For projections, a simple expression would look like this, where the property is actually a path:</p>

<pre class="csharpcode">              <span class="kwrd">&lt;</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Property</span><span class="kwrd">&gt;</span>$Target/Path[Relationship='RelationshipName']/Property[Type='ClassName']/PropertyName$<span class="kwrd">&lt;/</span><span class="html">Property</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">Operator</span><span class="kwrd">&gt;</span>Equal<span class="kwrd">&lt;/</span><span class="html">Operator</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>3<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;/</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Also, rather than using names, you can use Ids in the criteria:</p>

<pre class="csharpcode">              <span class="kwrd">&lt;</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Property</span><span class="kwrd">&gt;</span>$Target/Property[Type='b982d3ec-96e0-4901-b1d9-a06196acf0bc']/b982d3ec-96e0-4901-b1d9-a06196acf0bc$<span class="kwrd">&lt;/</span><span class="html">Property</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">Operator</span><span class="kwrd">&gt;</span>Equal<span class="kwrd">&lt;/</span><span class="html">Operator</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>3<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;/</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>or:</p>

<pre class="csharpcode">            <span class="kwrd">&lt;</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Property</span><span class="kwrd">&gt;</span>$Target/Path[Relationship='b982d3ec-96e0-4901-b1d9-a06196acf0bc']/<br />Property[Type='b982d3ec-96e0-4901-b1d9-a06196acf0bc']/b982d3ec-96e0-4901-b1d9-a06196acf0bc$<span class="kwrd">&lt;/</span><span class="html">Property</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">Operator</span><span class="kwrd">&gt;</span>Equal<span class="kwrd">&lt;/</span><span class="html">Operator</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>3<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p><strong><em>Unary/Regex Expression
      <br /></em></strong>These are the same as the simple expressions, but instead Unary and RegEx operators are supported. RegExExpression supports ContainsSubstring, MatchesWildcard, MatchesRegularExpression, DoesNotContainSubstring, DoesNotMatchWildcard and DoesNotMatchRegularExpression. UnaryExpression supports IsNull and IsNotNull.</p>

<p><strong><em>Contains/NotContains/ContainedBy/NotContainedBy Expression
      <br /></em></strong>These expressions allow a traversal to be made either down or up containment to either include or exclude results based the existence of a relationship to other instances. The concept here is similar to an EXISTS query in SQL. </p>

<pre class="csharpcode">          <span class="kwrd">&lt;</span><span class="html">Contains</span><span class="kwrd">&gt;</span>
            <span class="rem">&lt;!-- A Contains query from a particular node in the projection; this can also just drop path and the implicit path is the seed --&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Path</span><span class="kwrd">&gt;</span>$Target/Path[Relationship='RelationshipName']$<span class="kwrd">&lt;/</span><span class="html">Path</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Class</span><span class="kwrd">&gt;</span>$MPElement[Name='System!System.Computer']$<span class="kwrd">&lt;/</span><span class="html">Class</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Expression</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Property</span><span class="kwrd">&gt;</span>$Target/Property[Type='System!System.Computer']/FQDN$<span class="kwrd">&lt;/</span><span class="html">Property</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionLeft</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">Operator</span><span class="kwrd">&gt;</span>Equal<span class="kwrd">&lt;/</span><span class="html">Operator</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
                  <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>ComputerName<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;/</span><span class="html">ValueExpressionRight</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;/</span><span class="html">SimpleExpression</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">Expression</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span><span class="html">Contains</span><span class="kwrd">&gt;</span></pre>

<p>The Path element indicates where within the context of the criteria you want to perform the containment based query. If the path is excluded, it means that you want the containment query to be done on the target of the criteria, namely the projection seed class or the class in the case of regular instance queries.</p>

<p>As a more concrete example, given an Incident projection with System.Incident as the seed and a single related owner System.User, one can do containment based queries on either the incident or the user. If a query like &#8220;Give me all incidents that are contained by the &#8216;Tier 1 Incident Group&#8217;&#8221;, the path element would be excluded, the Class element would point to the Incident Group type and the expression would be empty. If there were some criteria on that group that needed to be matched, that expression would be used for that. If the query was like &#8220;Give me incidents that have a owner that is contained by &#8220;Tier 1 Users Group&#8221;, the path element would need to be populated pointing to System.User.</p>

<p>It is important to note that the path element indicates where in the context of the criteria you want the containment query to apply, while the class and criteria indicate what you are searching for in that containment space.</p>

<p><strong><em>And/Or Expression
      <br /></em></strong>These expressions allow you to combine other expressions.</p>

<p><strong><em>In Expression
      <br /></em></strong>And finally we support a basic IN clause for use with Guid fields only. The other thing to note here is that I am using a GenericProperty instead of Property element. This allows you to refer to generic properties of instances that aren't modeled. This property also has a Path attribute that allows you to point to a node in a projection for which you want the generic property to apply.</p>

<pre class="csharpcode">    <span class="kwrd">&lt;</span><span class="html">Expression</span><span class="kwrd">&gt;</span>
      <span class="rem">&lt;!-- Simple IN Clause (GUID support only) --&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">In</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">GenericProperty</span><span class="kwrd">&gt;</span>Id<span class="kwrd">&lt;/</span><span class="html">GenericProperty</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Values</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>b982d3ec-96e0-4901-b1d9-a06196acf0bc<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>b982d3ec-96e0-4901-b1d9-a06197acf0bc<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">Value</span><span class="kwrd">&gt;</span>b982d3ec-96e0-4901-b1d9-a06198acf0bc<span class="kwrd">&lt;/</span><span class="html">Value</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Values</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">In</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Expression</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>]]></content:encoded>
    </item>
    <item>
      <title>MMS 2009</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/mms-2009</link>
      <pubDate>Tue, 14 Apr 2009 12:16:51 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/04/14/mms-2009/</guid>
      <description><![CDATA[I apologize for not posting lately, we've been really heads down on Beta 2 and working on our...]]></description>
      <content:encoded><![CDATA[<p>I apologize for not posting lately, we've been really heads down on Beta 2 and working on our sessions for MMS. I plan to post more regularly again when things die down a bit, but in the meantime just wanted to let you know that I'll be at MMS doing the session below. If anyone is also going to be there, come check out our talk.</p>  <p>&#160;<strong>SO23 Customizing and Extending Service Manager      <br /></strong><em>Speaker(s): Jakub Oleksy, Travis Wright      <br />Track(s): Operations Management       <br />Session Type(s): Breakout Session       <br />Products(s): Operations Manager 2007, Service Manager</em></p>  <p>A technical drill-down on the customization capabilities of Service Manager: This session will articulate how to extend and deliver Service Manager through the delivery of management packs. We will demonstrate the authoring tools to learn how to create workflows, customize templates and extend the configuration management database </p>]]></content:encoded>
    </item>
    <item>
      <title>Getting and Working With Type Projections - Basic</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/getting-and-working-with-type-projections-basic</link>
      <pubDate>Tue, 03 Mar 2009 20:47:28 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/03/03/getting-and-working-with-type-projections-basic/</guid>
      <description><![CDATA[In my last post in gave you a more in-depth look at creating type projections in Service Manager. In...]]></description>
      <content:encoded><![CDATA[<p>In my <a href="https://blogs.msdn.com/jakuboleksy/archive/2009/02/04/more-with-type-projections.aspx">last post</a> in gave you a more in-depth look at creating type projections in Service Manager. In this post, I'd like to provide you with some basic examples on how you can retrieve and work with instances of type projections. I'll be using the same Management Pack and data set from the previous post.</p>  <p>On the Instances interface you will find a few methods for retrieving instances of EnterpriseManagementObjectProjection. Post Beta 1, we've actually cleaned up this interface significantly so I don't want to concentrate too much on the actual method call, but rather the parameters to it and working with the result. </p>  <p>In Beta 1 the method you would use looks like this:</p>  <pre class="csharpcode">IList&lt;EnterpriseManagementObjectProjection&gt; GetObjectProjections&lt;T&gt;(ManagementPackTypeProjection managementPackTypeProjection, <br />ObjectProjectionCriteria criteria, ObjectQueryOptions queryOptions) <span class="kwrd">where</span> T : EnterpriseManagementObject;</pre>

<p>Post Beta 1, this method is replaced by:</p>

<pre class="csharpcode">IObjectProjectionReader&lt;T&gt; GetObjectProjectionReader&lt;T&gt;(ObjectProjectionCriteria criteria, ObjectQueryOptions queryOptions)
            <span class="kwrd">where</span> T : EnterpriseManagementObject;</pre>

<p>The ManagementPackTypeProjection from the first simply gets rolled into the ObjectProjectionCriteria object and the return type gets changed to support buffered reads to help with performance, however, IObjectProjectionReader can actually be used like an IList (although it doesn't implement IList); I'll discuss the reader more once we ship Beta 2 later this year. My examples below will use the latest code since that will be around longer; hopefully it is easily transferable for you to the Beta 1 API.</p>

<p>The first thing you need in order to get a type projection instance, is the type projection definition. This narrows down the types of instances you will get back to those that fit the structure of the type projection:</p>

<pre class="csharpcode">      <span class="rem">// Connect to the management group</span>
      EnterpriseManagementGroup managementGroup =
            <span class="kwrd">new</span> EnterpriseManagementGroup(<span class="str">&quot;localhost&quot;</span>);

      <span class="rem">// Get the management pack</span>
      ManagementPack nflManagementPack = 
            managementGroup.ManagementPacks.GetManagementPack(<span class="str">&quot;NFL&quot;</span>, <span class="kwrd">null</span>, <span class="kwrd">new</span> Version(<span class="str">&quot;1.0.0.0&quot;</span>));

      <span class="rem">// Get the type projection</span>
      ManagementPackTypeProjection nflProjection =
            nflManagementPack.GetTypeProjection(<span class="str">&quot;NFL.Conference.All&quot;</span>);</pre>

<p>Very simply you can retrieve projections by specifying the type:</p>

<blockquote>
  <pre class="csharpcode">IObjectProjectionReader&lt;EnterpriseManagementObject&gt; objectProjections =
      managementGroup.Instances.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(
      <span class="kwrd">new</span> ObjectProjectionCriteria(nflProjection), ObjectQueryOptions.Default);</pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>This will retrieve all projections in the system of that structure. A projection exists if the root object of the projection exists, regardless of whether any of the components are found. If you want to limit your result somehow, you will need to specify criteria to limit your result set. One example of simple criteria you could add is matching on one of the generic properties of the root object:</p>

<pre class="csharpcode">            <span class="kwrd">string</span> displayNameCriteria = <span class="str">@&quot;&lt;Criteria xmlns=&quot;</span><span class="str">&quot;https://Microsoft.EnterpriseManagement.Core.Criteria/&quot;</span><span class="str">&quot;&gt;
                  &lt;Expression&gt;
                    &lt;SimpleExpression&gt;
                      &lt;ValueExpressionLeft&gt;
                        &lt;GenericProperty&gt;DisplayName&lt;/GenericProperty&gt;
                      &lt;/ValueExpressionLeft&gt;
                      &lt;Operator&gt;Equal&lt;/Operator&gt;
                      &lt;ValueExpressionRight&gt;
                        &lt;Value&gt;National Football Conference&lt;/Value&gt;
                      &lt;/ValueExpressionRight&gt;
                    &lt;/SimpleExpression&gt;
                  &lt;/Expression&gt;
                &lt;/Criteria&gt;&quot;</span>;

            IObjectProjectionReader&lt;EnterpriseManagementObject&gt; objectProjectionsByDisplayName =
                 managementGroup.Instances.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(
                     <span class="kwrd">new</span> ObjectProjectionCriteria(displayNameCriteria, nflProjection, managementGroup), ObjectQueryOptions.Default);</pre>

<p>This would limit the results to any projections whose root object had a display name matching &quot;National Football Conference.&quot; The list of available generic properties for Service Manager is Id, Name, DisplayName, LastModified and new post Beta 1 CreatedDate and LastModifiedBy. </p>

<p>It is also possible to query on type specific properties of the root object:</p>

<pre class="csharpcode">            <span class="kwrd">string</span> propertyCriteria = <span class="str">@&quot;&lt;Criteria xmlns=&quot;</span><span class="str">&quot;https://Microsoft.EnterpriseManagement.Core.Criteria/&quot;</span><span class="str">&quot;&gt;
                  &lt;Expression&gt;
                    &lt;SimpleExpression&gt;
                      &lt;ValueExpressionLeft&gt;
                        &lt;Property&gt;$Target/Property[Type='NFL.Conference']/Name$&lt;/Property&gt;
                      &lt;/ValueExpressionLeft&gt;
                      &lt;Operator&gt;Equal&lt;/Operator&gt;
                      &lt;ValueExpressionRight&gt;
                        &lt;Value&gt;NFC&lt;/Value&gt;
                      &lt;/ValueExpressionRight&gt;
                    &lt;/SimpleExpression&gt;
                  &lt;/Expression&gt;
                &lt;/Criteria&gt;&quot;</span>;

            IObjectProjectionReader&lt;EnterpriseManagementObject&gt; objectProjectionsByProperty =
                 managementGroup.Instances.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(
                     <span class="kwrd">new</span> ObjectProjectionCriteria(propertyCriteria, nflProjection, nflManagementPack, managementGroup), ObjectQueryOptions.Default);</pre>

<p></p>

<p><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>Criteria can get more complicated than the above examples, including specifying criteria on the individual components of the projection, but an in-depth discussion will happen in a later post. </p>

<p>Once you get an EnterpriseManagementObjectProjection, you essentially have a collection of instances organized in a hierarchy as defined by the type projection. If you run the following code:</p>

<pre class="csharpcode"><span class="kwrd">            foreach</span> (EnterpriseManagementObjectProjection projection <span class="kwrd">in</span> objectProjections)
            {
                Console.WriteLine(<span class="str">&quot;Conference: {0}&quot;</span>, projection.Object.DisplayName);
                <span class="kwrd">foreach</span> (IComposableProjection division <span class="kwrd">in</span> projection[nflConferenceContainsDivision.Target])
                {
                    Console.WriteLine(<span class="str">&quot;\tDivision: {0}&quot;</span>, division.Object.DisplayName);
                    <span class="kwrd">foreach</span> (IComposableProjection team <span class="kwrd">in</span> division[divisionContainTeam.Target])
                    {
                        Console.WriteLine(<span class="str">&quot;\t\tTeam: {0}&quot;</span>, team.Object.DisplayName);
                        <span class="kwrd">foreach</span> (IComposableProjection coach <span class="kwrd">in</span> team[coachCoachesTeam.Source])
                        {
                            Console.WriteLine(<span class="str">&quot;\t\t\tCoach: {0}&quot;</span>, coach.Object.DisplayName);
                        }
                    }
                }
            }</pre>

<p>You'll get a result that shows you the structure of the projection in memory:</p>

<p><em>Conference: American Football Conference
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: AFC West

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Oakland Raiders

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Kansas City Chiefs

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: San Diego Chargers

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Denver Broncos

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: AFC East

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Buffalo Bills

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: New England Patriots

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: New York Jets

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Miami Dolphins

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: AFC South

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Houston Texans

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Jacksonville Jaguars

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Tennessee Titans

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Indianapolis Colts

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: AFC North

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Cleveland Browns

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Pittsburgh Steelers

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Baltimore Ravens

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Cincinnati Bengals

    <br />Conference: National Football Conference

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: NFC North

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Green Bay Packers

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Chicago Bears

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Coach: Lovie Smith

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Detroit Lions

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Minnesota Vikings

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: NFC South

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Carolina Panthers

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Atlanta Falcons

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Tampa Bay Buccaneers

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: New Orleans Saints

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: NFC East

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: New York Giants

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Dallas Cowboys

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Philadelphia Eagles

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Washington Redskins

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Division: NFC West

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: St. Louis Rams

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Seattle Seahawks

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: Arizona Cardinals

    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Team: San Francisco 49ers</em></p>

<p>If the line is indented, it indicates a jump across a relationship. The hierarchy is organized by the relationship types that bring in each component; put another way, as you traverse from parent to child you are traversing a relationship of a particular relationship type in one direction. So, as you go from <em>American Football Conference</em> to <em>AFC West<strong>, </strong></em>you are moving from &quot;Conference&quot; to &quot;Division&quot; on the NFL.ConferenceHostsDivision relationship type. </p>

<p>Each node in an EnterpriseManagementObjectProjection implements IComposableProjection which offers various ways at traversing through the hierarchy. The object is also IEnumerable&lt;KeyValuePair&lt;ManagementPackRelationshipEndpoint, IComposableProjection&gt;&gt;, which shows that the hierarchy is organized by the relationship endpoint that brings each node in. You also get a pointer to the actual object at the node:</p>

<pre class="csharpcode">        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// The current object in the projection.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        EnterpriseManagementObject Object
        {
            get;
        }</pre>

<p></p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>The role that brought the current object into the current projection:</p>

<pre class="csharpcode">        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Gets the role of this projection, relative to its parent.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;value&gt;&lt;/value&gt;</span>
        ManagementPackRelationshipEndpoint ObjectRole
        {
            get;
        }</pre>

<p>The object that brought the current object into the current projection:</p>

<pre class="csharpcode">        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// The parent object, if any, for the current object in the projection.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IComposableProjection ParentObject
        {
            get;
        }</pre>

<p><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>And a few indexers to aid in traversal, one of which we used in the sample above:</p>

<pre class="csharpcode">        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Access all IComposableProjection elements of this IComposableProjection, optionally recursively.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IList&lt;IComposableProjection&gt; <span class="kwrd">this</span>[TraversalDepth traversalDepth]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Access IComposableProjection elements of this IComposableProjection, by role name.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IList&lt;IComposableProjection&gt; <span class="kwrd">this</span>[<span class="kwrd">string</span> roleName]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Access IComposableProjection elements of this IComposableProjection, by role name.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IList&lt;IComposableProjection&gt; <span class="kwrd">this</span>[<span class="kwrd">string</span> roleName, ManagementPackClass classConstraint]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Gets the IComposableProjection child of the projection by id of the contained object</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IComposableProjection <span class="kwrd">this</span>[<span class="kwrd">string</span> roleName, Guid id]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Access IComposableProjection elements of this IComposableProjection, by relationship role.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IList&lt;IComposableProjection&gt; <span class="kwrd">this</span>[ManagementPackRelationshipEndpoint role]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Access IComposableProjection elements of this IComposableProjection, by relationship role and a class constraint.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IList&lt;IComposableProjection&gt; <span class="kwrd">this</span>[ManagementPackRelationshipEndpoint role, ManagementPackClass classConstraint]
        {
            get;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Gets the IComposableProjection child of the projection by id of the contained object</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        IComposableProjection <span class="kwrd">this</span>[ManagementPackRelationshipEndpoint role, Guid id]
        {
            get;
        }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>In future posts I'll discuss more advanced concepts around working with projections instances (they're IXPathNavigable!), a deeper look at criteria, creating and editing projections and a lot more. I hope that by the time Beta 2 ships later this year to have a comprehensive list of topics that help introduce you to new API concepts. <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>]]></content:encoded>
    </item>
    <item>
      <title>More with Type Projections</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/more-with-type-projections</link>
      <pubDate>Wed, 04 Feb 2009 12:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/02/04/more-with-type-projections/</guid>
      <description><![CDATA[In my last post I introduced you to a new concept in the Service Manager infrastructure called Type...]]></description>
      <content:encoded><![CDATA[<p>In my <a href="https://blogs.msdn.com/jakuboleksy/archive/2009/01/20/getting-started-with-type-projections.aspx" mce_href="https://blogs.msdn.com/jakuboleksy/archive/2009/01/20/getting-started-with-type-projections.aspx">last post</a> I introduced you to a new concept in the Service Manager infrastructure called Type Projections. Here, I want to expand on my previous example and discuss type projection structure in more depth. I've attached the management pack that I will be discussing (NFL.xml) and there is reference code at the bottom of this post for populating sample data.</p>  <p>Type projection definitions allow users to create virtual object collections through any relationships found in the system. In the previous post I showed how a projection could bring hosted and host objects together in one go. The following projection expands on that example by introducing System.Containment and System.Reference relationships, as well as introducing the concepts of type constraints and relationship direction:</p>  <pre class="csharpcode">      <span class="kwrd">&lt;</span><span class="html">TypeProjections</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TypeProjection</span> <span class="attr">ID</span><span class="kwrd">=&quot;NFL.Conference.All&quot;</span> <span class="attr">Accessibility</span><span class="kwrd">=&quot;Public&quot;</span> <span class="attr">Type</span><span class="kwrd">=&quot;NFL.Conference&quot;</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">Component</span> <span class="attr">Alias</span><span class="kwrd">=&quot;Division&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;$Target/Path[Relationship='NFL.ConferenceHostsDivision']$&quot;</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Component</span> <span class="attr">Alias</span><span class="kwrd">=&quot;AFCTeam&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;$Target/Path[Relationship='NFL.DivisionContainsTeam' SeedRole='Source' TypeConstraint='AFC.Team']$&quot;</span><span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Component</span> <span class="attr">Alias</span><span class="kwrd">=&quot;NFCTeam&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;$Target/Path[Relationship='NFL.DivisionContainsTeam' SeedRole='Source' TypeConstraint='NFC.Team']$&quot;</span><span class="kwrd">&gt;</span>
              <span class="kwrd">&lt;</span><span class="html">Component</span> <span class="attr">Alias</span><span class="kwrd">=&quot;Coach&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;$Target/Path[Relationship='NFL.CoachCoachesTeam' SeedRole='Target']$&quot;</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">Component</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span><span class="html">Component</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">TypeProjection</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">TypeProjections</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Added to the Division component from the previous post, I've now introduced two components that bring in all the teams in the NFL. I've defined my NFL.Team class as abstract and created concrete classes, AFC.Team and NFC.Team. I've also created a relationship derived from System.Containment associating an NFL.Division to an NFL.Team. Of note is that this relationship ends with an abstract class as the target endpoint. While this is supported by type projection definitions, the projection I have defined actually demonstrates the ability to constraint a component to a particular class. The two components, AFCTeam and NFCTeam each share a relationship, however, they each add a different type constraint. Given something can't be an NFCTeam and AFCTeam at the same time, these components will introduce unique sets of data.</p>

<p>If I were to change the AFCTeam component to remove the type constraint, that component would return all NFL.Team instances while the NFCTeam component would return only those NFL.Team objects that are NFC.Teams as well. </p>

<p>Next, I added a System.Reference relationship between NFL.Coach and NFL.Team. Notice that the coach is the source of that relationship. If I want to include all coaches for NFC.Teams, I need to indicate in the type projection definition that I want to traverse the relationship from target to source. This is done via the SeedRole attribute. The &quot;Seed&quot; refers to the parent component of the current component; the attribute describes which role the seed should play relative to the relationship used in the current component. In the sample, the relationship is NFL.CoachCoachesTeam and the seed (NFCTeam) is the target of that relationship and hence SeedRole='Target'.</p>

<p>Traversing this structure is similar to the example in my previous post:</p>

<pre class="csharpcode">            <span class="rem">// Connect to the management group</span>
            EnterpriseManagementGroup managementGroup =
                <span class="kwrd">new</span> EnterpriseManagementGroup(<span class="str">&quot;localhost&quot;</span>);

            <span class="rem">// Get the management pack</span>
            ManagementPack nflManagementPack = 
                managementGroup.ManagementPacks.GetManagementPack(<span class="str">&quot;NFL&quot;</span>, <span class="kwrd">null</span>, <span class="kwrd">new</span> Version(<span class="str">&quot;1.0.0.0&quot;</span>));

            <span class="rem">// Get the type projection</span>
            ManagementPackTypeProjection nflProjection =
                nflManagementPack.GetTypeProjection(<span class="str">&quot;NFL.Conference.All&quot;</span>);

            <span class="rem">// Get the relationship types</span>
            ManagementPackRelationship nflConferenceContainsDivision =
                nflManagementPack.GetRelationship(<span class="str">&quot;NFL.ConferenceHostsDivision&quot;</span>);

            ManagementPackRelationship divisionContainTeam =
                nflManagementPack.GetRelationship(<span class="str">&quot;NFL.DivisionContainsTeam&quot;</span>);

            ManagementPackRelationship coachCoachesTeam =
                nflManagementPack.GetRelationship(<span class="str">&quot;NFL.CoachCoachesTeam&quot;</span>);

            IObjectProjectionReader&lt;EnterpriseManagementObject&gt; objectProjections =
                managementGroup.Instances.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(
                    <span class="kwrd">new</span> ObjectProjectionCriteria(nflProjection), ObjectQueryOptions.Default);

            <span class="kwrd">foreach</span> (EnterpriseManagementObjectProjection projection <span class="kwrd">in</span> objectProjections)
            {
                Console.WriteLine(<span class="str">&quot;Conference: {0}&quot;</span>, projection.Object.DisplayName);
                <span class="kwrd">foreach</span> (IComposableProjection division <span class="kwrd">in</span> projection[nflConferenceContainsDivision.Target])
                {
                    Console.WriteLine(<span class="str">&quot;\tDivision: {0}&quot;</span>, division.Object.DisplayName);
                    <span class="kwrd">foreach</span> (IComposableProjection team <span class="kwrd">in</span> division[divisionContainTeam.Target])
                    {
                        Console.WriteLine(<span class="str">&quot;\t\tTeam: {0}&quot;</span>, team.Object.DisplayName);
                        <span class="kwrd">foreach</span> (IComposableProjection coach <span class="kwrd">in</span> team[coachCoachesTeam.Source])
                        {
                            Console.WriteLine(<span class="str">&quot;\t\t\tCoach: {0}&quot;</span>, coach.Object.DisplayName);
                        }
                    }
                }
            }</pre>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>When we traverse from team to coach, we use the .Source property of the relationship which corresponds to the SeedRole description in the type projection definition. As part of traversing the projection, think of the role as where you are traversing to; in this example you are traversing from the team (the .Target property) to the coach (the .Source property). </p>

<p>When traversing from divisions to teams, I am using the abstract .Target property of the NFL.DivisionContainsTeam relationship. Type constraints are not expressed in the traversal mechanism for these objects; the key from going to one component to another is the relationship endpoint, save any type constraints. </p>

<p><strong>Reference Code</strong></p>

<pre class="csharpcode">           <span class="rem">// Connect to the management group</span>
            EnterpriseManagementGroup managementGroup =
                <span class="kwrd">new</span> EnterpriseManagementGroup(<span class="str">&quot;localhost&quot;</span>);

            <span class="rem">// Import the management pack</span>
            ManagementPack managementPack = <span class="kwrd">new</span> ManagementPack(<span class="str">&quot;NFL.xml&quot;</span>);
            managementGroup.ManagementPacks.ImportManagementPack(managementPack);
            managementPack = managementGroup.ManagementPacks.GetManagementPack(managementPack.Id);

            <span class="rem">// Populate Data</span>
            IncrementalDiscoveryData dataTransaction = <span class="kwrd">new</span> IncrementalDiscoveryData();

            <span class="rem">// Get System.Entity class</span>
            ManagementPackClass systemEntity = managementGroup.EntityTypes.GetClass(SystemClass.Entity);

            <span class="rem">// Conferences</span>
            ManagementPackClass conference = managementPack.GetClass(<span class="str">&quot;NFL.Conference&quot;</span>);
            CreatableEnterpriseManagementObject nfc = <span class="kwrd">new</span> CreatableEnterpriseManagementObject(managementGroup, conference);
            nfc[conference, <span class="str">&quot;Name&quot;</span>].Value = <span class="str">&quot;NFC&quot;</span>;
            nfc[systemEntity, <span class="str">&quot;DisplayName&quot;</span>].Value = <span class="str">&quot;National Football Conference&quot;</span>;
            dataTransaction.Add(nfc);

            CreatableEnterpriseManagementObject afc = <span class="kwrd">new</span> CreatableEnterpriseManagementObject(managementGroup, conference);
            afc[conference, <span class="str">&quot;Name&quot;</span>].Value = <span class="str">&quot;AFC&quot;</span>;
            afc[systemEntity, <span class="str">&quot;DisplayName&quot;</span>].Value = <span class="str">&quot;American Football Conference&quot;</span>;
            dataTransaction.Add(afc);

            <span class="rem">// Divisions</span>
            Dictionary&lt;<span class="kwrd">string</span>, List&lt;<span class="kwrd">string</span>&gt;&gt; divisions = <span class="kwrd">new</span> Dictionary&lt;<span class="kwrd">string</span>,List&lt;<span class="kwrd">string</span>&gt;&gt;();
            divisions.Add(<span class="str">&quot;AFC North&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;AFC North&quot;</span>].Add(<span class="str">&quot;Baltimore Ravens&quot;</span>);
            divisions[<span class="str">&quot;AFC North&quot;</span>].Add(<span class="str">&quot;Cincinnati Bengals&quot;</span>);
            divisions[<span class="str">&quot;AFC North&quot;</span>].Add(<span class="str">&quot;Cleveland Browns&quot;</span>);
            divisions[<span class="str">&quot;AFC North&quot;</span>].Add(<span class="str">&quot;Pittsburgh Steelers&quot;</span>);
            divisions.Add(<span class="str">&quot;NFC North&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;NFC North&quot;</span>].Add(<span class="str">&quot;Chicago Bears&quot;</span>);
            divisions[<span class="str">&quot;NFC North&quot;</span>].Add(<span class="str">&quot;Detroit Lions&quot;</span>);
            divisions[<span class="str">&quot;NFC North&quot;</span>].Add(<span class="str">&quot;Green Bay Packers&quot;</span>);
            divisions[<span class="str">&quot;NFC North&quot;</span>].Add(<span class="str">&quot;Minnesota Vikings&quot;</span>);
            
            divisions.Add(<span class="str">&quot;AFC South&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;AFC South&quot;</span>].Add(<span class="str">&quot;Houston Texans&quot;</span>);
            divisions[<span class="str">&quot;AFC South&quot;</span>].Add(<span class="str">&quot;Indianapolis Colts&quot;</span>);
            divisions[<span class="str">&quot;AFC South&quot;</span>].Add(<span class="str">&quot;Jacksonville Jaguars&quot;</span>);
            divisions[<span class="str">&quot;AFC South&quot;</span>].Add(<span class="str">&quot;Tennessee Titans&quot;</span>);
            divisions.Add(<span class="str">&quot;NFC South&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;NFC South&quot;</span>].Add(<span class="str">&quot;Atlanta Falcons&quot;</span>);
            divisions[<span class="str">&quot;NFC South&quot;</span>].Add(<span class="str">&quot;Carolina Panthers&quot;</span>);
            divisions[<span class="str">&quot;NFC South&quot;</span>].Add(<span class="str">&quot;New Orleans Saints&quot;</span>);
            divisions[<span class="str">&quot;NFC South&quot;</span>].Add(<span class="str">&quot;Tampa Bay Buccaneers&quot;</span>);

            divisions.Add(<span class="str">&quot;AFC East&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;AFC East&quot;</span>].Add(<span class="str">&quot;Buffalo Bills&quot;</span>);
            divisions[<span class="str">&quot;AFC East&quot;</span>].Add(<span class="str">&quot;Miami Dolphins&quot;</span>);
            divisions[<span class="str">&quot;AFC East&quot;</span>].Add(<span class="str">&quot;New England Patriots&quot;</span>);
            divisions[<span class="str">&quot;AFC East&quot;</span>].Add(<span class="str">&quot;New York Jets&quot;</span>);
            divisions.Add(<span class="str">&quot;NFC East&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;NFC East&quot;</span>].Add(<span class="str">&quot;Dallas Cowboys&quot;</span>);
            divisions[<span class="str">&quot;NFC East&quot;</span>].Add(<span class="str">&quot;New York Giants&quot;</span>);
            divisions[<span class="str">&quot;NFC East&quot;</span>].Add(<span class="str">&quot;Philadelphia Eagles&quot;</span>);
            divisions[<span class="str">&quot;NFC East&quot;</span>].Add(<span class="str">&quot;Washington Redskins&quot;</span>);

            divisions.Add(<span class="str">&quot;AFC West&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;AFC West&quot;</span>].Add(<span class="str">&quot;Denver Broncos&quot;</span>);
            divisions[<span class="str">&quot;AFC West&quot;</span>].Add(<span class="str">&quot;Kansas City Chiefs&quot;</span>);
            divisions[<span class="str">&quot;AFC West&quot;</span>].Add(<span class="str">&quot;Oakland Raiders&quot;</span>);
            divisions[<span class="str">&quot;AFC West&quot;</span>].Add(<span class="str">&quot;San Diego Chargers&quot;</span>);
            divisions.Add(<span class="str">&quot;NFC West&quot;</span>, <span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;());
            divisions[<span class="str">&quot;NFC West&quot;</span>].Add(<span class="str">&quot;Arizona Cardinals&quot;</span>);
            divisions[<span class="str">&quot;NFC West&quot;</span>].Add(<span class="str">&quot;San Francisco 49ers&quot;</span>);
            divisions[<span class="str">&quot;NFC West&quot;</span>].Add(<span class="str">&quot;Seattle Seahawks&quot;</span>);
            divisions[<span class="str">&quot;NFC West&quot;</span>].Add(<span class="str">&quot;St. Louis Rams&quot;</span>);

            Dictionary&lt;<span class="kwrd">string</span>, <span class="kwrd">string</span>&gt; teamToCoach = <span class="kwrd">new</span> Dictionary&lt;<span class="kwrd">string</span>, <span class="kwrd">string</span>&gt;();
            teamToCoach.Add(<span class="str">&quot;Chicago Bears&quot;</span>, <span class="str">&quot;Lovie Smith&quot;</span>);

            ManagementPackClass divisionClass = managementPack.GetClass(<span class="str">&quot;NFL.Division&quot;</span>);
            ManagementPackClass nfcTeamClass = managementPack.GetClass(<span class="str">&quot;NFC.Team&quot;</span>);
            ManagementPackClass afcTeamClass = managementPack.GetClass(<span class="str">&quot;AFC.Team&quot;</span>);
            ManagementPackClass coachClass = managementPack.GetClass(<span class="str">&quot;NFL.Coach&quot;</span>);

            ManagementPackRelationship divisionContainsTeamClass = managementPack.GetRelationship(<span class="str">&quot;NFL.DivisionContainsTeam&quot;</span>);
            ManagementPackRelationship coachCoachesTeamClass = managementPack.GetRelationship(<span class="str">&quot;NFL.CoachCoachesTeam&quot;</span>);
            <span class="kwrd">foreach</span> (<span class="kwrd">string</span> divisionName <span class="kwrd">in</span> divisions.Keys)
            {
                CreatableEnterpriseManagementObject division = <span class="kwrd">new</span> CreatableEnterpriseManagementObject(managementGroup, divisionClass);

                <span class="kwrd">string</span> conferenceName;
                ManagementPackClass teamClass;

                <span class="kwrd">if</span> (divisionName.Contains(<span class="str">&quot;AFC&quot;</span>) == <span class="kwrd">true</span>)
                {
                    conferenceName = <span class="str">&quot;AFC&quot;</span>;
                    teamClass = afcTeamClass;
                }
                <span class="kwrd">else</span>
                {
                    conferenceName = <span class="str">&quot;NFC&quot;</span>;
                    teamClass = nfcTeamClass;
                }

                <span class="rem">// Need to make sure to set key values of the host</span>
                division[conference, <span class="str">&quot;Name&quot;</span>].Value = conferenceName;
                division[divisionClass, <span class="str">&quot;Name&quot;</span>].Value = divisionName;
                division[systemEntity, <span class="str">&quot;DisplayName&quot;</span>].Value = divisionName;
                dataTransaction.Add(division);
                <span class="kwrd">foreach</span> (<span class="kwrd">string</span> teamName <span class="kwrd">in</span> divisions[divisionName])
                {
                    CreatableEnterpriseManagementObject team = <span class="kwrd">new</span> CreatableEnterpriseManagementObject(managementGroup, teamClass);
                    team[teamClass, <span class="str">&quot;Name&quot;</span>].Value = teamName;
                    team[systemEntity, <span class="str">&quot;DisplayName&quot;</span>].Value = teamName;
                    dataTransaction.Add(team);

                    CreatableEnterpriseManagementRelationshipObject divisionContainsTeam = <br />                               <span class="kwrd">new</span> CreatableEnterpriseManagementRelationshipObject(managementGroup, divisionContainsTeamClass);
                    divisionContainsTeam.SetSource(division);
                    divisionContainsTeam.SetTarget(team);
                    dataTransaction.Add(divisionContainsTeam);

                    <span class="kwrd">if</span> (teamToCoach.ContainsKey(teamName) == <span class="kwrd">true</span>)
                    {
                        CreatableEnterpriseManagementObject coach = <span class="kwrd">new</span> CreatableEnterpriseManagementObject(managementGroup, coachClass);
                        coach[coachClass, <span class="str">&quot;Name&quot;</span>].Value = teamToCoach[teamName];
                        coach[systemEntity, <span class="str">&quot;DisplayName&quot;</span>].Value = teamToCoach[teamName];
                        dataTransaction.Add(coach);

                        CreatableEnterpriseManagementRelationshipObject coachCoachesTeam = <br />                                      <span class="kwrd">new</span> CreatableEnterpriseManagementRelationshipObject(managementGroup, coachCoachesTeamClass);
                        coachCoachesTeam.SetSource(coach);
                        coachCoachesTeam.SetTarget(team);
                        dataTransaction.Add(coachCoachesTeam);
                    }
                }
            }

            <span class="rem">// Use Overwrite instead of Commit here because I want to bypass optimistic concurrency checks which will not allow the </span>
            <span class="rem">// insertion of an existing instances and I want this method to be re-runnable</span>
            dataTransaction.Overwrite(managementGroup);</pre>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/39/61/44/NFL.xml" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-39-61-44/NFL.xml">NFL.xml</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Getting Started with Type Projections</title>
      <link>https://docs.microsoft.com/archive/blogs/jakuboleksy/getting-started-with-type-projections</link>
      <pubDate>Tue, 20 Jan 2009 13:41:00 GMT</pubDate>
      <dc:creator><![CDATA[Jakub Oleksy [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jakuboleksy/2009/01/20/getting-started-with-type-projections/</guid>
      <description><![CDATA[A very powerful new concept in the SDK is the notion of Type Projections. I always describe type...]]></description>
      <content:encoded><![CDATA[<P>A very powerful new concept in the SDK is the notion of Type Projections. I always describe type projections as a view over our type system, much like a SQL view over tables, with the added capability that our type projections are hierarchal. What projections allow you to do is query over and retrieve collections of objects related somehow in our model in one go. In this post I want to provide a very simply example of how to define and retrieve a type projection, and in future posts I will dive much deeper into working with them.</P>
<P>For this post, I've attached a management pack (NFL.xml) that defines the classes and type projection used in the sample code. Also, I have the code I used to populate my objects in the <STRONG>Reference Code</STRONG> section below.</P>
<P>In the management pack you will notice two classes defined, <STRONG>NFL.Conference</STRONG> and <STRONG>NFL.Division</STRONG>, and a hosting relationship type, <STRONG>NFL.ConferenceHostsDivision</STRONG>, between them. My scenario is that I want to display all the conferences and divisions in the UI, so I define a type projection that puts the two classes together:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>TypeProjection</SPAN> <SPAN class=attr>ID</SPAN><SPAN class=kwrd>="NFL.Conference.All"</SPAN> <SPAN class=attr>Accessibility</SPAN><SPAN class=kwrd>="Public"</SPAN> <SPAN class=attr>Type</SPAN><SPAN class=kwrd>="NFL.Conference"</SPAN><SPAN class=kwrd>&gt;</SPAN>
     <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Component</SPAN> <SPAN class=attr>Alias</SPAN><SPAN class=kwrd>="Division"</SPAN> <SPAN class=attr>Path</SPAN><SPAN class=kwrd>="$Target/Path[Relationship='NFL.ConferenceHostsDivision']$"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>TypeProjection</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>The first thing you should notice in the above definition is the Type property on the root element; this defines the type of instance that should exist at the root or "seed" of the projection. Next, you'll notice the projection has one component, <STRONG>Division</STRONG>, that relates to the root. The Path attribute is what defines how to find the desired component, relative to the seed. I will describe the path notation in more depth in future posts, but here Target refers to the seed element of the projection (an instance of <STRONG>NFL.Conference</STRONG>), followed by a Path construct that tells the system to follow the <STRONG>NFL.ConferenceHostsDivision</STRONG> relationship type.&nbsp; This will result in a structure that looks like this:</P>
<P><STRONG>* NFL.Conference</STRONG> </P>
<BLOCKQUOTE>
<P><STRONG>* NFL.Division</STRONG></P></BLOCKQUOTE>
<P>Now, in order to work with this, the SDK has introduced a new object type, EnterpriseManagementObjectProjection, along with an interface, IComposableProjection, to allow for retrieval of and then navigation of the returned structure. The following code shows a basic example of retrieving and iterating through the objects:</P><PRE class=csharpcode>            <SPAN class=rem>// Connect to the management group</SPAN>
            EnterpriseManagementGroup managementGroup =
                <SPAN class=kwrd>new</SPAN> EnterpriseManagementGroup(<SPAN class=str>"localhost"</SPAN>);

            <SPAN class=rem>// Get the management pack</SPAN>
            ManagementPack nflManagementPack = 
                managementGroup.ManagementPacks.GetManagementPack(<SPAN class=str>"NFL"</SPAN>, <SPAN class=kwrd>null</SPAN>, <SPAN class=kwrd>new</SPAN> Version(<SPAN class=str>"1.0.0.0"</SPAN>));

            <SPAN class=rem>// Get the type projection</SPAN>
            ManagementPackTypeProjection nflProjection = 
                nflManagementPack.GetTypeProjection(<SPAN class=str>"NFL.Conference.All"</SPAN>);

            <SPAN class=rem>// Get the relationship type</SPAN>
            ManagementPackRelationship nflConferenceContainsDivision = 
                nflManagementPack.GetRelationship(<SPAN class=str>"NFL.ConferenceHostsDivision"</SPAN>);

            IObjectProjectionReader&lt;EnterpriseManagementObject&gt; objectProjections =
                managementGroup.Instances.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(
                    <SPAN class=kwrd>new</SPAN> ObjectProjectionCriteria(nflProjection), ObjectQueryOptions.Default);

            <SPAN class=kwrd>foreach</SPAN> (EnterpriseManagementObjectProjection projection <SPAN class=kwrd>in</SPAN> objectProjections)
            {
                Console.WriteLine(<SPAN class=str>"Conference {0}"</SPAN>, projection.Object.DisplayName);
                <SPAN class=kwrd>foreach</SPAN> (IComposableProjection division <SPAN class=kwrd>in</SPAN> projection[nflConferenceContainsDivision.Target])
                {
                    Console.WriteLine(<SPAN class=str>"Division {0}"</SPAN>, division.Object.DisplayName);
                }
            }</PRE>
<P>The sample first connects to the server and retrieves the type projection definition which is necessary for interacting with the SDK and the relationship type definition which is necessary for navigating the resulting instance. Next, we get an IObjectProjectionReader&lt;EnterpriseManagementObject&gt; that will contain all instances of our type projection. Finally, the example shows how to iterate through the object and get data. </P>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P><STRONG>Reference Code</STRONG></P><PRE class=csharpcode>            <SPAN class=rem>// Connect to the management group</SPAN>
            EnterpriseManagementGroup managementGroup =
                <SPAN class=kwrd>new</SPAN> EnterpriseManagementGroup(<SPAN class=str>"localhost"</SPAN>);

            <SPAN class=rem>// Import the management pack</SPAN>
            ManagementPack managementPack = <SPAN class=kwrd>new</SPAN> ManagementPack(<SPAN class=str>"NFL.xml"</SPAN>);
            managementGroup.ManagementPacks.ImportManagementPack(managementPack);
            managementPack = managementGroup.ManagementPacks.GetManagementPack(managementPack.Id);

            <SPAN class=rem>// Populate Data</SPAN>
            IncrementalDiscoveryData dataTransaction = <SPAN class=kwrd>new</SPAN> IncrementalDiscoveryData();

            <SPAN class=rem>// Get System.Entity class</SPAN>
            ManagementPackClass systemEntity = managementGroup.EntityTypes.GetClass(SystemClass.Entity);

            <SPAN class=rem>// Conferences</SPAN>
            ManagementPackClass conference = managementPack.GetClass(<SPAN class=str>"NFL.Conference"</SPAN>);
            CreatableEnterpriseManagementObject nfc = <SPAN class=kwrd>new</SPAN> CreatableEnterpriseManagementObject(managementGroup, conference);
            nfc[conference, <SPAN class=str>"Name"</SPAN>].Value = <SPAN class=str>"NFC"</SPAN>;
            nfc[systemEntity, <SPAN class=str>"DisplayName"</SPAN>].Value = <SPAN class=str>"National Football Conference"</SPAN>;
            dataTransaction.Add(nfc);

            CreatableEnterpriseManagementObject afc = <SPAN class=kwrd>new</SPAN> CreatableEnterpriseManagementObject(managementGroup, conference);
            afc[conference, <SPAN class=str>"Name"</SPAN>].Value = <SPAN class=str>"AFC"</SPAN>;
            afc[systemEntity, <SPAN class=str>"DisplayName"</SPAN>].Value = <SPAN class=str>"American Football Conference"</SPAN>;
            dataTransaction.Add(afc);

            <SPAN class=rem>// Divisions</SPAN>
            ManagementPackClass division = managementPack.GetClass(<SPAN class=str>"NFL.Division"</SPAN>);
            <SPAN class=kwrd>string</SPAN>[] nfcDivisionNames = <SPAN class=kwrd>new</SPAN> <SPAN class=kwrd>string</SPAN>[] {
                <SPAN class=str>"NFC East"</SPAN>,
                <SPAN class=str>"NFC North"</SPAN>,
                <SPAN class=str>"NFC South"</SPAN>,
                <SPAN class=str>"NFC West"</SPAN>
            };
            
            <SPAN class=kwrd>foreach</SPAN> (<SPAN class=kwrd>string</SPAN> nfcDivisionName <SPAN class=kwrd>in</SPAN> nfcDivisionNames)
            {
                CreatableEnterpriseManagementObject nfcDivision = <SPAN class=kwrd>new</SPAN> CreatableEnterpriseManagementObject(managementGroup, division);
                
                <SPAN class=rem>// Need to make sure to set key values of the host</SPAN>
                nfcDivision[conference, <SPAN class=str>"Name"</SPAN>].Value = <SPAN class=str>"NFC"</SPAN>;
                
                nfcDivision[division, <SPAN class=str>"Name"</SPAN>].Value = nfcDivisionName;
                nfcDivision[systemEntity, <SPAN class=str>"DisplayName"</SPAN>].Value = nfcDivisionName;
                dataTransaction.Add(nfcDivision);
            }

            <SPAN class=kwrd>string</SPAN>[] afcDivisionNames = <SPAN class=kwrd>new</SPAN> <SPAN class=kwrd>string</SPAN>[] {
                <SPAN class=str>"AFC East"</SPAN>,
                <SPAN class=str>"AFC North"</SPAN>,
                <SPAN class=str>"AFC South"</SPAN>,
                <SPAN class=str>"AFC West"</SPAN>
            };

            <SPAN class=kwrd>foreach</SPAN> (<SPAN class=kwrd>string</SPAN> afcDivisionName <SPAN class=kwrd>in</SPAN> afcDivisionNames)
            {
                CreatableEnterpriseManagementObject afcDivision = <SPAN class=kwrd>new</SPAN> CreatableEnterpriseManagementObject(managementGroup, division);

                <SPAN class=rem>// Need to make sure to set key values of the host</SPAN>
                afcDivision[conference, <SPAN class=str>"Name"</SPAN>].Value = <SPAN class=str>"AFC"</SPAN>;

                afcDivision[division, <SPAN class=str>"Name"</SPAN>].Value = afcDivisionName;
                afcDivision[systemEntity, <SPAN class=str>"DisplayName"</SPAN>].Value = afcDivisionName;
                dataTransaction.Add(afcDivision);
            }

            <SPAN class=rem>// Use Overwrite instead of Commit here because I want to bypass optimistic concurrency checks which will not allow the </SPAN>
            <SPAN class=rem>// insertion of an existing instances and I want this method to be re-runnable</SPAN>
            dataTransaction.Overwrite(managementGroup);</PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/34/97/41/NFL.xml" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-34-97-41/NFL.xml">NFL.xml</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>