Category Archives: LINQ

LINQ

LINQ doesn’t have the equivalent of the SQL “IS NULL” operator. e.g. SELECT * FROM dbTable where dbColumn IS NULL In LINQ to write a query against nullable column, fashion the query as, var results = from a in dbTable where a.dbColumn == null select a; or string myVar = null; var myRows = from […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> Entity Framework, LINQ | Comments Off on LINQ

Learning LINQ – Extension methods

Extension methods can be used to extend the set of methods that you can use for LINQ queries, namespace TestConsoleApplication { class Program { static void Main(string[] args) { int[] myNumbers = { 1, 2, 3, 4, 5,7 }; // the j=>j lambda expression as a parameter to the method so compiler // implicitly converts […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> .NET, Entity Framework, LINQ, Microsoft | Comments Off on Learning LINQ – Extension methods

Learning LINQ

Learning LINQ and the various nuances, including how C# 3.0 features are leveraged. Anonymous Types var test = new {Field1=value1, Field2=value2}; var fullName = new {FirstName=”Susan”, LastName=”Howe”}; Extension Methods List customers = new List(); customers.Add(new Customer(1,”Roger”,”Minnesota”)); customers.Add(new Customer(2,”Susan”,”San Francisco”)); customers.Add(new Customer(3,”Hector”,”New York”)); var abe = collection.Single(c => c.Name.Equals(“Hector”)); Lambda Expressions (int i) => {return i […]

<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> LINQ | Comments Off on Learning LINQ