Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Test For Null
Message
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Test For Null
Divers
Thread ID:
01467359
Message ID:
01467359
Vues:
109
I have this:
var query = from g in root.Groups
            from r in g.Rules
            from c in r.Conditions
            from a in c.Actions
            where g.Rules != null
            where r.Conditions != null
            where c.Actions != null
            where a.ActionID == ActionId
            select a;

List<RuleAction> items = query.ToList();
RetVal = items[0];
It fails on the last line with "Object reference not set to an instance of an object" because the query returned no results.

How do I test for this before attempting to convert the results to a list?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform