Hello,
Very new to c Sharp and trying to query CRM 365 CE and I noticed that if a field comes back as blank or null it gives me this error?
In general how do you check for this and it's normal to have lots of nulls on any of the fields how does one handle that?
using (OrganizationServiceContext context = new OrganizationServiceContext(service))
{
// Pull contacts
var query = from account in context.CreateQuery("account")
join contact in context.CreateQuery("contact")
on account["primarycontactid"] equals contact["contactid"]
// where account["address1_city"] == "Woodland Hills" //&& account["name"] == "Peak Financial"
//where contact["fullname"] == "Dan Russ"
select new
{
Name = account["name"],
//Email = (contact["emailaddress1"] != null && contact["emailaddress1"] != ""),
// fax =! contact.Contains("fax"),
// fax = account["fax"],
CName = contact["fullname"],
CEmail = contact["emailaddress1"],
Manager = contact
};
foreach (var account in query)
{
//service.Update()
//Console.WriteLine(account.Name + " is run by: " + account.Manager["fullname"] + " Email " + account.Email + " fax " + account.fax);
Console.WriteLine(account.Name);
Console.WriteLine(account.CName + " " + account.CEmail);
}
Console.Read();