Answers for "linq queryable cheat sheet"

SQL
0

linq cheat sheet

// Single() will throw an error if more than one result, or there is no result
	var lambda = Statuses.Single( s => s.Name == "Active");

	// SingleorDefault() will throw an error if more than one result, and null if there is no result
	var lambda = Statuses.SingleOrDefault( s => s.Name == "Active");

	// first() will throw an error if no results
	var lambda = PartNumbers.First( p => p.ModelId == 10001);

	//firstOrDefault will return null if no results
	var lambda = PartNumbers.FirstOrDefault( p => p.ModelId == 10001);
	var lambda = PartNumbers.FirstOrDefault();
Posted by: Guest on October-06-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language