title: How to access values from fetchedXML when using aliases to attributes in CRM Dynamics?
body: <p>I'm fetching a list of marketing lists. As I do so, it seems to be a successful operation according to my check using intellisense. When I look for <code>...Entities[0].Attributes["nick"]</code> I get an object (with the right data somewhere in it). But I can't access it programmatically (instead I have to click around like a monkey via the pluses to fold out the good stuff).</p>
  
  <p>In fact, I'm getting the entities as supposed to using the code below. The problem is that they aren't <code>Strings</code> according to the computer. They are of type <code>Microsoft.Xrm.Sdk.AliasedValue</code> and I don't know how to access the actual nick inside them.</p>
  
  <pre class="lang-cs prettyprint-override"><code>new Contact
  {
    Name = element.Attributes["nick"] as String,
    Mail = element.Attributes["mail"] as String
  }
  </code></pre>
  
  <p>Intellisense says that <code>Value</code> is in there (and it's the correct value too) but I can't access it by typing <code>.Value</code>. I suspect that I need to use "as" or something like that but at the moment I'm stuck. Any hints? <code>As</code>'ing it to <code>String</code>, which is supposed to work, gives me <code>null</code>...</p>
  
  <p>I've read <a href="http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.aliasedvalue_members.aspx" rel="noreferrer">this article</a> and several others like it and the way I see it, I'm supposed to be able to access all the fun stuff in there. I can't though...</p>
  
  <p>I've noticed that the following code gets me the data I'm so desperately trying to get but <strong>this</strong> can't be a professional syntax, can it?! Seriously, it looks like a high school student with ADHD and hangover tried to do that...</p>
  
  <pre class="lang-cs prettyprint-override"><code>new Contact
  {
    Name = ((Microsoft.Xrm.Sdk.AliasedValue)result.Entities[0].Attributes["nick"]).Value,
    Mail = ((Microsoft.Xrm.Sdk.AliasedValue)result.Entities[0].Attributes["mail"]).Value
  }
  </code></pre>
  
  <p>I mean, seriously - this is one ugly piece of code... There's got to be a better way! However, I fear there's not because <a href="http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/e3a4e5a9-1797-481f-8d66-fd2cd4abf560/" rel="noreferrer">this discussion</a> seems to be using that syntax as well...</p>