Click here to Skip to main content
14,383,822 members

.NET Framework

 
QuestionUsing Linq Join within the Where clause of another Linq Query Pin
simpledeveloper19-Nov-19 10:44
membersimpledeveloper19-Nov-19 10:44 
AnswerRe: Using Linq Join within the Where clause of another Linq Query Pin
Gerry Schmitz20-Nov-19 8:00
mveGerry Schmitz20-Nov-19 8:00 
GeneralRe: Using Linq Join within the Where clause of another Linq Query Pin
simpledeveloper20-Nov-19 8:33
membersimpledeveloper20-Nov-19 8:33 
QuestionDropping Columns referenced by other Tables Pin
simpledeveloper19-Nov-19 7:57
membersimpledeveloper19-Nov-19 7:57 
AnswerRe: Dropping Columns referenced by other Tables Pin
Gerry Schmitz20-Nov-19 7:54
mveGerry Schmitz20-Nov-19 7:54 
GeneralRe: Dropping Columns referenced by other Tables Pin
simpledeveloper20-Nov-19 8:39
membersimpledeveloper20-Nov-19 8:39 
GeneralRe: Dropping Columns referenced by other Tables Pin
simpledeveloper21-Nov-19 17:36
membersimpledeveloper21-Nov-19 17:36 
QuestionLinq to check before it creates select Pin
simpledeveloper15-Nov-19 15:04
membersimpledeveloper15-Nov-19 15:04 
Hi, I have a Linq query as follows

NOVId = (v.NOVId != null ? new List<int> { v.NOVId ?? default(int) }
    : (from n in novs where n.Violations.Any(a => a.ViolationId == v.ViolationId) select v.NOVId ?? default(int)).ToList())


, what I want is, it is failing at n.Violations or a.ViolationId, since there are some novs which do not have violations, how can I fix this? that it shouldn't fail, just goes through without errors or exceptions - means this shhould select only if n.Violations has violations otherwise just return either 0 or null - any help please? Thanks in advance.

And in similar way I have a Linq query in the following way, where if some value becomes null within from, then avoid the select
Violations = from vv in n.Violations
             select new
             {
                 ViolationNumber = vv.ViolationNumber,
                 ViolationId = vv.ViolationId,
                 inspectionItemNum = (inspectionItems != null && inspectionItems.Count() > 0) ?
                 (from i in inspectionItems where i.Violations.Any(v => v.ViolationId == vv.ViolationId) select i.InspectionItemNumber)
                 : null
             }

So in the above Linq query, if the vv becomes null, I don't want select new to be executed as it is going to throw exception, how can I handle this situation in C# - thanks again.

modified 15-Nov-19 21:22pm.

SuggestionRe: Linq to check before it creates select Pin
Richard Deeming17-Nov-19 23:47
mveRichard Deeming17-Nov-19 23:47 
QuestionMessage Closed Pin
15-Nov-19 2:05
memberangelosia15-Nov-19 2:05 
QuestionMessage Closed Pin
15-Nov-19 2:04
memberangelosia15-Nov-19 2:04 
QuestionMessage Closed Pin
15-Nov-19 2:03
memberangelosia15-Nov-19 2:03 
QuestionMessage Closed Pin
14-Nov-19 0:58
memberjems mariya14-Nov-19 0:58 
QuestionVB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 1:31
memberEmanuela Meraglia8-Nov-19 1:31 
AnswerRe: VB6 dll calls from WCF Pin
Richard MacCutchan8-Nov-19 2:30
protectorRichard MacCutchan8-Nov-19 2:30 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:11
memberEmanuela Meraglia8-Nov-19 3:11 
GeneralMessage Closed Pin
19-Nov-19 20:07
professionalandreelew9219-Nov-19 20:07 
AnswerRe: VB6 dll calls from WCF Pin
Richard Deeming8-Nov-19 2:31
mveRichard Deeming8-Nov-19 2:31 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:11
memberEmanuela Meraglia8-Nov-19 3:11 
GeneralRe: VB6 dll calls from WCF Pin
Richard Deeming8-Nov-19 4:32
mveRichard Deeming8-Nov-19 4:32 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 4:44
memberEmanuela Meraglia8-Nov-19 4:44 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:14
memberEmanuela Meraglia8-Nov-19 3:14 
GeneralRe: VB6 dll calls from WCF Pin
simpledeveloper20-Nov-19 8:49
membersimpledeveloper20-Nov-19 8:49 
QuestionRe: VB6 dll calls from WCF Pin
Eddy Vluggen8-Nov-19 2:39
mveEddy Vluggen8-Nov-19 2:39 
AnswerRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:23
memberEmanuela Meraglia8-Nov-19 3:23 

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.