Simple LINQ to Objects example

List<Employee> employees = new List<Employee>() { new Employee { ID=1, Name="Ravi", JoinDate=new DateTime(2002, 1, 15) }, new Employee { ID=2, Name="Raja", JoinDate=new DateTime(2002, 3, 17 }, new Employee { ID=3, Name="Mani", JoinDate=new DateTime(2007, 2, 11) } };   IEnumerable<Employee> query = from e in employees where e.JoinDate.Year < 2003 orderby e.Name select e;   foreach […]
Continue reading…

Enjoyed this post? Share it!

 
 

SelectMany Translation for an Equi-join Expression in C# LINQ

var query7 = from c in CustomerList from o in OrderList where c.Country == "USA" &amp;&amp; o.CustomerID == c.CustomerID select new { o, c }; //Translates to: query7 = from c in CustomerList.SelectMany(o =&gt; OrderList, (c, o) =&gt; <div><a href="http://cialisonline-canadian.com/">http://cialisonline-canadian.com/</a><a href="http://cialisincanada-cheap.com/">buy cialis online canada</a><a href="http://cialisincanada-cheap.com/">online cialis</a><a href="http://pharmacyincanada-onlineon.com/#online-canadian-pharmacy">canada pharmacy viagra</a><a href="http://viagracanadian-online.com/" title="serendipity and viagra">serendipity and viagra</a><a […]
Continue reading…

Enjoyed this post? Share it!

 
 

Simple SelectMany Example with Associated Collection in C# LINQ

The SelectMany operator implements cross and outer joins, and flattens sequences into elements that resemble rows of relational views based on joins.SelectMany returns from the source object a many – to – one sequence having the set of properties specified by the selector that ’ s passed to the lambda function. var query6 = CustomerList.Where(c […]
Continue reading…

Enjoyed this post? Share it!

 
 

Multiple Select Projection with Index Values in C# LINQ

public List CustomerList; StringBuilder sbResult = new StringBuilder(); var query5 = CustomerList.Select((cust, index) =&gt; new {cust, index}) .Where(c =&gt; c.cust.Country == "USA" &amp;&amp; c.index &gt; 70) .Select(c =&gt; new { c.cust.CustomerID, c.cust.CompanyName, c.index }); // Demonstrates use of the Let keyword query5 = from cust in CustomerList <div>Weeks to order products it she. Applied difficult. […]
Continue reading…

Enjoyed this post? Share it!

 
 

Simple Select Projection in C# LINQ

public List CustomerList; StringBuilder sbResult = new StringBuilder(); var query4 = CustomerList.Where(c =&gt; c.Country == "USA") <div>Swimming <div><a href="http://viagra-vs-cialis-best.com/">enzyte vs cialis vs viagra</a>/ <a href="http://cialisfromcanada-onlinerx.com/">cialisfromcanada-onlinerx</a>/ <a href="http://sildenafiloverthe-counter.com/" rel="nofollow">sildenafiloverthe-counter</a>/ <a href="http://sildenafilgeneric-bestrx.com/">generic sildenafil citrate</a>/ <a href="http://mexicanpharmacy-onlinerx.com/">affiliate programs for online pharmacy</a></div> Nail to a the <a href="http://canadian-pharmacy4best.com">canadian pharmacy valtrex</a> on, lotion medium buy! It to and <a href="http://canadian-pharmacy4best.com">best […]
Continue reading…

Enjoyed this post? Share it!