简体   繁体   中英

MS Dynamics Query audit in C# returning EntityReference instead of name

I know that in order to request audit details for a specific record, I need to use a call like this:

var changedBy = auditDetailsResponse.AudtiDetail.AuditRecord.Attributes["userid"];

But in the console, I'm getting returns like this:

Changed By: Microsoft.Xrm.Sdk.EntityReference

Trying this:

var changedBy = (EntityReference)auditDetailsResponse.AudtiDetail.AuditRecord.Attributes["userid"];

Yields the same result.

What am I doing wrong?

Try accessing like this.

var changedById = ((EntityReference)auditDetailsResponse.AudtiDetail.AuditRecord.Attributes["userid"]).Id;

var changedByName = ((EntityReference)auditDetailsResponse.AudtiDetail.AuditRecord.Attributes["userid"]).Name;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM