Click here to Skip to main content
15,880,725 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionUsing Linq Join within the Where clause of another Linq Query Pin
simpledeveloper19-Nov-19 9:44
simpledeveloper19-Nov-19 9:44 
AnswerRe: Using Linq Join within the Where clause of another Linq Query Pin
Gerry Schmitz20-Nov-19 7:00
mveGerry Schmitz20-Nov-19 7:00 
GeneralRe: Using Linq Join within the Where clause of another Linq Query Pin
simpledeveloper20-Nov-19 7:33
simpledeveloper20-Nov-19 7:33 
QuestionDropping Columns referenced by other Tables Pin
simpledeveloper19-Nov-19 6:57
simpledeveloper19-Nov-19 6:57 
AnswerRe: Dropping Columns referenced by other Tables Pin
Gerry Schmitz20-Nov-19 6:54
mveGerry Schmitz20-Nov-19 6:54 
GeneralRe: Dropping Columns referenced by other Tables Pin
simpledeveloper20-Nov-19 7:39
simpledeveloper20-Nov-19 7:39 
GeneralRe: Dropping Columns referenced by other Tables Pin
simpledeveloper21-Nov-19 16:36
simpledeveloper21-Nov-19 16:36 
QuestionLinq to check before it creates select Pin
simpledeveloper15-Nov-19 14:04
simpledeveloper15-Nov-19 14: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 22:47
mveRichard Deeming17-Nov-19 22:47 
QuestionVB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 0:31
Emanuela Meraglia8-Nov-19 0:31 
AnswerRe: VB6 dll calls from WCF Pin
Richard MacCutchan8-Nov-19 1:30
mveRichard MacCutchan8-Nov-19 1:30 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 2:11
Emanuela Meraglia8-Nov-19 2:11 
AnswerRe: VB6 dll calls from WCF Pin
Richard Deeming8-Nov-19 1:31
mveRichard Deeming8-Nov-19 1:31 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 2:11
Emanuela Meraglia8-Nov-19 2:11 
GeneralRe: VB6 dll calls from WCF Pin
Richard Deeming8-Nov-19 3:32
mveRichard Deeming8-Nov-19 3:32 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:44
Emanuela Meraglia8-Nov-19 3:44 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 2:14
Emanuela Meraglia8-Nov-19 2:14 
GeneralRe: VB6 dll calls from WCF Pin
simpledeveloper20-Nov-19 7:49
simpledeveloper20-Nov-19 7:49 
QuestionRe: VB6 dll calls from WCF Pin
Eddy Vluggen8-Nov-19 1:39
professionalEddy Vluggen8-Nov-19 1:39 
AnswerRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 2:23
Emanuela Meraglia8-Nov-19 2:23 
GeneralRe: VB6 dll calls from WCF Pin
Eddy Vluggen8-Nov-19 2:27
professionalEddy Vluggen8-Nov-19 2:27 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 2:31
Emanuela Meraglia8-Nov-19 2:31 
GeneralRe: VB6 dll calls from WCF Pin
Eddy Vluggen8-Nov-19 2:56
professionalEddy Vluggen8-Nov-19 2:56 
GeneralRe: VB6 dll calls from WCF Pin
Emanuela Meraglia8-Nov-19 3:12
Emanuela Meraglia8-Nov-19 3:12 
GeneralRe: VB6 dll calls from WCF Pin
Eddy Vluggen8-Nov-19 3:42
professionalEddy Vluggen8-Nov-19 3:42 

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.