Object not set to instance of object: When using api with LINQ

Hey all,

I love using the user API to gather information about our users. Recently I am getting errors on code that once worked flawlessly. It is returning an error of Object isn't set to an instance of an object. Here are the lines leading up to the error:

var apiUser = new UserAPI();
var linqQuery = from u in apiUser.GetUsers(1000,1).Entities select u.Name, u.Email;

I also have tried doing getUsers into a separate variable then doing the LINQ with the same error. Is there some setting I need to add to have it wait until the data is loaded or am I doing something wrong?

*Note: I typed the code on my cellphone so the syntax may not be perfect.

You have may a user with a NULL email or name, does it work if you try ;

UsersApi apiUser = new UsersApi();      
var linqQuery = from u in apiUser.GetUsers(1000, 1).Entities select new { Name = u.Name ?? "", Email = u.Email ?? ""  };

The issue was that we had users without titles and they where showing up as null. So I ended up just adding titles onto anyone who didn't have one already. That was the ultimate fix. But thank you for the suggestion. I plan on using this somewhere else.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.