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 ...Entities[0].Attributes["nick"]
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).
In fact, I'm getting the entities as supposed to using the code below. The problem is that they aren't Strings
according to the computer. They are of type Microsoft.Xrm.Sdk.AliasedValue
and I don't know how to access the actual nick inside them.
new Contact
{
Name = element.Attributes["nick"] as String,
Mail = element.Attributes["mail"] as String
}
Intellisense says that Value
is in there (and it's the correct value too) but I can't access it by typing .Value
. I suspect that I need to use "as" or something like that but at the moment I'm stuck. Any hints? As
'ing it to String
, which is supposed to work, gives me null
...
I've read this article 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...
I've noticed that the following code gets me the data I'm so desperately trying to get but this can't be a professional syntax, can it?! Seriously, it looks like a high school student with ADHD and hangover tried to do that...
new Contact
{
Name = ((Microsoft.Xrm.Sdk.AliasedValue)result.Entities[0].Attributes["nick"]).Value,
Mail = ((Microsoft.Xrm.Sdk.AliasedValue)result.Entities[0].Attributes["mail"]).Value
}
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 this discussion seems to be using that syntax as well...