This code is joining incident & systemusers entity.


//link users

                        queryIncident.LinkEntities.Add(new LinkEntity("incident", "systemuser", "modifiedby", "systemuserid", JoinOperator.LeftOuter));

                        queryIncident.LinkEntities[6].EntityAlias = "users";

                        queryIncident.LinkEntities[6].Columns.AddColumns(

                            "fullname",

                            "domainname",

                            "businessunitid"

                            );


I have no problem retrieving "fullname" & "domainname" value using below lines.

string entRefUsersFullName = entIncident.Contains("users.fullname") ? entIncident.GetAttributeValue<AliasedValue>("users.fullname").Value.ToString() : "";

string entRefUsersDomainName = entIncident.Contains("users.domainname") ? entIncident.GetAttributeValue<AliasedValue>("users.domainname").Value.ToString() : "";


But I'm unable to do so for "businessunitid". I'm receiving "Microsoft.Xrm.Sdk.AliasedValue" error when i run below line. Any advise?

var businessunitID = entIncident.GetAttributeValue<AliasedValue>("users.businessunitid");

var businessunitGUID = businessunitID.ToString();