LINQ joins

I will use two classes, to demonstrate my examples:

Continue reading

Advertisements
By Sriramjithendra Posted in LINQ

Var and IEnumerable with LINQ

 IEnumerable is an interface that can move forward only over a collection, it can’t move backward and between the items. Var is used to declare implicitly typed local variable means it tells the compiler to figure out the type of the variable at compilation time. A var variable must be initialized at the time of declaration. Both have its own importance to query data and data manipulation. Continue reading

Handling Nullable values in LINQ queries.

Suppose we have PhoneNum (nullable integer property) in Customer class
Public int PhoneNum {get;set;}

Check Null in lamda expression like below.

Public Ienumerable<Customer> GetCutomers(List<Customer> custList)
{
var query=custList.Where(c => (c.PhoneNum ?? false)== false);
}