Click here to Skip to main content
15,896,154 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to display alert in system tray using c# Pin
Eddy Vluggen23-Sep-16 6:22
professionalEddy Vluggen23-Sep-16 6:22 
QuestionCreate own language translator in C# Pin
Member 1051770422-Sep-16 21:47
Member 1051770422-Sep-16 21:47 
AnswerRe: Create own language translator in C# Pin
Pete O'Hanlon22-Sep-16 21:57
mvePete O'Hanlon22-Sep-16 21:57 
GeneralRe: Create own language translator in C# Pin
Member 1051770423-Sep-16 0:55
Member 1051770423-Sep-16 0:55 
GeneralRe: Create own language translator in C# Pin
Pete O'Hanlon23-Sep-16 1:04
mvePete O'Hanlon23-Sep-16 1:04 
GeneralRe: Create own language translator in C# Pin
Member 1051770423-Sep-16 1:42
Member 1051770423-Sep-16 1:42 
GeneralRe: Create own language translator in C# Pin
Pete O'Hanlon23-Sep-16 1:54
mvePete O'Hanlon23-Sep-16 1:54 
GeneralRe: Create own language translator in C# Pin
Member 1051770425-Sep-16 19:42
Member 1051770425-Sep-16 19:42 
GeneralRe: Create own language translator in C# Pin
Pete O'Hanlon25-Sep-16 20:35
mvePete O'Hanlon25-Sep-16 20:35 
GeneralRe: Create own language translator in C# Pin
Dave Kreskowiak23-Sep-16 2:15
mveDave Kreskowiak23-Sep-16 2:15 
GeneralRe: Create own language translator in C# Pin
OriginalGriff23-Sep-16 1:57
mveOriginalGriff23-Sep-16 1:57 
GeneralRe: Create own language translator in C# Pin
Jammer24-Sep-16 1:46
Jammer24-Sep-16 1:46 
GeneralRe: Create own language translator in C# Pin
Pete O'Hanlon24-Sep-16 3:23
mvePete O'Hanlon24-Sep-16 3:23 
AnswerRe: Create own language translator in C# Pin
OriginalGriff22-Sep-16 22:58
mveOriginalGriff22-Sep-16 22:58 
AnswerRe: Create own language translator in C# Pin
Gerry Schmitz24-Sep-16 6:34
mveGerry Schmitz24-Sep-16 6:34 
QuestionHaving Trouble With this code Pin
RizingPhoenix21-Sep-16 8:42
RizingPhoenix21-Sep-16 8:42 
AnswerRe: Having Trouble With this code Pin
Richard Deeming21-Sep-16 8:54
mveRichard Deeming21-Sep-16 8:54 
AnswerRe: Having Trouble With this code Pin
Ahmad Bukhari21-Sep-16 20:01
Ahmad Bukhari21-Sep-16 20:01 
AnswerRe: Having Trouble With this code Pin
RizingPhoenix21-Sep-16 20:57
RizingPhoenix21-Sep-16 20:57 
SuggestionRe: Having Trouble With this code Pin
Richard Deeming22-Sep-16 1:54
mveRichard Deeming22-Sep-16 1:54 
GeneralRe: Having Trouble With this code Pin
Kelly Herald2-Nov-16 9:22
Kelly Herald2-Nov-16 9:22 
QuestionFileSystemWatcher in c # Pin
Luis_Saenz21-Sep-16 4:46
Luis_Saenz21-Sep-16 4:46 
SuggestionRe: FileSystemWatcher in c # Pin
ZurdoDev21-Sep-16 5:05
professionalZurdoDev21-Sep-16 5:05 
AnswerRe: FileSystemWatcher in c # Pin
Maciej Los21-Sep-16 5:08
mveMaciej Los21-Sep-16 5:08 
QuestionJSON.Net - Error when I get value from a JToken that could be either a JValue or JArray Pin
inquisitive_121-Sep-16 3:48
inquisitive_121-Sep-16 3:48 
I'm trying to select all users with a roleId of 4. How can I do that? Here's my JSON string:
JavaScript
{
		"?xml" : {
			"@version" : "1.0",
			"@encoding" : "UTF-8"
		},
		"DataFeed" : {
			"@FeedName" : "AdminData",
			"People" : [{
					"id" : "63",
					"active" : "1",
					"firstName" : "Joe",
					"lastName" : "Schmoe",
					"roleIds" : {
						"int" : "4"
					}
				} , {
					"id" : "65",
					"active" : "1",
					"firstName" : "Steve",
					"lastName" : "Jobs",
					"roleIds" : {
						"int" : ["4", "16", "25", "20", "21", "22", "17", "23", "18"]
					}
				} , {
					"id" : "66",
					"active" : "1",
					"firstName" : "Bill",
					"lastName" : "Gates",
					"roleIds" : {
						"int" : ["3", "16", "25", "20"]
					}
				}
			]
		}
	}

Here's the query that I'm using:
C#
JObject jsonFeed = JObject.Parse(jsonText);
	
	from people in jsonFeed.SelectTokens("DataFeed.People").SelectMany(i => i.ObjectsOrSelf())
	where (int)people["active"] == 1 && (int)people["roleIds.int"] == 4 // <-- this causes the error
	select new PeopleClass
	{
		Id = (int)people["id"],
		ResAnFName = (string)people["firstName"],
		ResAnLName = (string)people["lastName"]
	}


I'm getting the following error on (int)people["roleIds.int"] == 4:

ArgumentNullException: Value cannot be null.<br />
	Parameter name: value


In the end, my results should be: Joe Schmoe & Steve Jobs, only.

What am I doing wrong?

modified 21-Sep-16 12:13pm.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.