我正在使用LINQ从Microsoft Dynamics CRM Online检索帐户类型实体。我无法过滤特定格式化值的列表。我有正确的价值,但我收到零记录。 我创造我的连接是这样的:如何在Dynamics CRM 2011中查询(使用LINQ)FormattedValues
var connection = new CrmConnection("CRMOnline");
connection.ProxyTypesEnabled = true;
CrmOrganizationServiceContext _context = new CrmOrganizationServiceContext(connection);
我已经试过:
List<Account> items = _context.CreateQuery<Account>()
.Where(c => ((OptionSetValue)c["new_accreditationstatus"]).Equals(7))
.ToList();
和
List<Account> items = _context.CreateQuery<Account>()
.Where(c => c.GetFormattedAttributeValue("new_accreditationstatus") == "7"
.ToList();
和
List<Account> items = _context.CreateQuery<Account>()
.Where(c => c["new_accreditationstatus"] == "7"
.ToList();
最后就抛出一个System.Format异常。
正常属性的过滤器,即.Where(c => c.AccountNumber.StartsWith("2010"))
工作得很好。
如果您启用代理类型,为什么Account.new_accreditationstatus必须通过字符串键值来访问?它没有为它创建一个属性访问器吗? – Daryl 2012-07-11 19:01:04
什么类型的字段是new_accreditationstatus? – glosrob 2012-07-11 19:01:12
@Daryl它不。它只在属性集合中可用。我没有设置数据库,也没有通过网络服务访问。 – 2012-07-11 19:36:56