Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
GeneralRe: EF Repository Questions Pin
PIEBALDconsult8-Sep-11 3:10
mvePIEBALDconsult8-Sep-11 3:10 
AnswerRe: EF Repository Questions Pin
BobJanova8-Sep-11 3:40
BobJanova8-Sep-11 3:40 
GeneralRe: EF Repository Questions Pin
Matt U.8-Sep-11 4:37
Matt U.8-Sep-11 4:37 
QuestionBetter Way to Search for a Value in a List of KeyValuePairs??? Pin
NickPace7-Sep-11 7:59
NickPace7-Sep-11 7:59 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Pete O'Hanlon7-Sep-11 8:08
mvePete O'Hanlon7-Sep-11 8:08 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Ennis Ray Lynch, Jr.7-Sep-11 8:08
Ennis Ray Lynch, Jr.7-Sep-11 8:08 
GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
BillWoodruff7-Sep-11 19:37
professionalBillWoodruff7-Sep-11 19:37 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Dan Mos7-Sep-11 8:14
Dan Mos7-Sep-11 8:14 
NickPace wrote:
var someValue = someList.Where(kvp => kvp.Value.Equals(someStringValue)); // which doesn’t work

Not sure if it is a typo but you don't select anything in the line below

C#
var someValue = someList.Where(kvp => kvp.Value.Equals(someStringValue)); // which doesn’t work


It should be something like:
C#
var someValue = someList.Where(kvp => kvp.Value.Equals(someStringValue)).Select(kvp=>kvp).FirstOrDefault();


Than you could check if it exits simply by comparing someValue.Value with string.Empty.

If not found the FirstOrDefault() method will initialize it with the default values witch is string.Empty for strings.

But there are more speedier approaches to this such as Dictionary, HashTable...
All the best,

Dan

GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
NickPace7-Sep-11 9:12
NickPace7-Sep-11 9:12 
GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Matt U.7-Sep-11 11:02
Matt U.7-Sep-11 11:02 
GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
NickPace7-Sep-11 12:42
NickPace7-Sep-11 12:42 
GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Matt U.7-Sep-11 13:12
Matt U.7-Sep-11 13:12 
QuestionRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
MicroVirus8-Sep-11 4:34
MicroVirus8-Sep-11 4:34 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Abhinav S7-Sep-11 8:26
Abhinav S7-Sep-11 8:26 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Ian Shlasko7-Sep-11 10:06
Ian Shlasko7-Sep-11 10:06 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
PIEBALDconsult7-Sep-11 14:25
mvePIEBALDconsult7-Sep-11 14:25 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
Mehdi Gholam7-Sep-11 20:05
Mehdi Gholam7-Sep-11 20:05 
AnswerRe: Better Way to Search for a Value in a List of KeyValuePairs??? [modified] Pin
BillWoodruff7-Sep-11 20:38
professionalBillWoodruff7-Sep-11 20:38 
GeneralRe: Better Way to Search for a Value in a List of KeyValuePairs??? Pin
NickPace8-Sep-11 3:40
NickPace8-Sep-11 3:40 
QuestionC#.net expiration date Pin
classy_dog7-Sep-11 5:30
classy_dog7-Sep-11 5:30 
AnswerRe: C#.net expiration date Pin
GParkings7-Sep-11 5:37
GParkings7-Sep-11 5:37 
GeneralRe: C#.net expiration date Pin
classy_dog7-Sep-11 5:51
classy_dog7-Sep-11 5:51 
GeneralRe: C#.net expiration date Pin
GParkings7-Sep-11 6:20
GParkings7-Sep-11 6:20 
GeneralRe: C#.net expiration date Pin
kribo9-Sep-11 5:01
professionalkribo9-Sep-11 5:01 
Questionout of memory ! Pin
mersad007-Sep-11 4:34
mersad007-Sep-11 4:34 

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.