6

i would like to translate this request in LINQ to SQL:

SELECT * from Agir where NouvelIncident='1' AND facturable is null

My try:

 public static List<Agir> GetINDEFAgir()
 {
     DataClassesActilogDataContext db = ContextSingleton.GetDataContext();

     List<Agir> list;

     var v = from i in db.Agir
             where i.facturable is null && i.NouvelIncident == true
             select i;

     list = v.ToList();
     return list;

 }

Looks like "is null" is not allowed in LINQ to SQL... i have a mistake.

Thanks in advance for your help

2 Answers 2

13

Use ==, 'is' is to check types

public static List<Agir> GetINDEFAgir()
 {

 DataClassesActilogDataContext db = ContextSingleton.GetDataContext();

 List<Agir> list;

 var v = from i in db.Agir
         where i.facturable == null && i.NouvelIncident == true
         select i;

 list = v.ToList();
 return list;

 }
Sign up to request clarification or add additional context in comments.

Comments

1

Doesn't this work?

var v = from i in db.Agir
             where i.facturable == null && i.NouvelIncident == true
             select i;

Linq-to-SQL should translate that to the proper SQL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.