我想知道如何在早期绑定(bind)中使用 LINQ
在 CRM 2011
中获取选项集字段的标签。
我曾尝试使用 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 });
提前致谢。
最佳答案
您必须选择选项集字段才能访问格式化值:
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"]
关于c# - 在 LINQ 中获取选项集标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24980233/