我想知道如何在早期约束中使用CRM 2011
在LINQ
中获取选项集字段的标签。
我尝试使用FormattedValues["field_name"]
,但我收到了以下错误The given key was not present in the dictionary
。
var query = (from username in context.SystemUserSet
select new { username.FullName,
Manager = (username.ParentSystemUserId == null) ? string.Empty : username.ParentSystemUserId.Name,
DepartmentValue = username.new_Department,
Department = username.FormattedValues["new_Department"] ,
username.SystemUserId });
提前致谢。
答案 0 :(得分:0)
您必须选择选项设置字段才能访问格式化的值:
var query = (from username in context.SystemUserSet
select new { username.FullName,
username.filed_name
Manager = (username.ParentSystemUserId == null) ? string.Empty : username.ParentSystemUserId.Name,
DepartmentValue = username.new_Department,
Department = username.FormattedValues["new_Department"] ,
username.SystemUserId
})
没有看到你已经选择了它(你拼写错误的字段)。
始终使用小写。这是你的问题。
Department = username.FormattedValues["new_department"]