Tag: LINQ
Using or Operator in the Where Clause of LINQ in C#
Below is a sample code snippet demonstrating on how to use “Or” Operator in the Where Clause of Linq in C#? Using or Operator in the Where Clause of LINQ in C#
How to Get the Top 5 elements from a List in C# ?
If you want to get the top 5 elements from a list in C# or skip the first item and get the next five elements from a List , you can use the Take and the Skip methods. How to Get the Top 5 elements from a List in C# ? Below is a sample code snippet demonstrating the usage of the Skip and Take…
How to Concatenate Strings in C# using LINQ?
Assume that you have an array/List of string which needs to be concatenated. One can concatenate strings using + operator, StringBuilder etc. . . . How about concatenating strings using LINQ? Below is a sample source code that demonstrates how to concatenate strings in C# using LINQ? How to Concatenate Strings in C# using LINQ?
Anonymous Types are read-only in C#
If you try to set a value to the anonymous type in C# , you will receive an compiler error . The properties within the anonymous types are read-only properties. Anonymous Types are read-only in C# In the above code snippet , you will receive an compiler error “Error CS0200 Property or indexer ‘<anonymous type: string FirstName, string Last>.FirstName’ cannot be assigned to — it…
Convert All Strings in a List to Upper Case using LINQ in C#
Below is a sample code snippet which demonstrates on how to convert all strings in a list to upper case using LINQ in C#.
?
How to Create Composite Anonymous Type in C#?
Below is a sample code snippet demonstrating how to How to Create Composite Anonymous Type in C#? How to Create Composite Anonymous Type in C#?
How to Perform Inner Join using LINQ in C# ?
Are you looking for the syntax on how to perform inner join using LINQ in C# ? . Below is a sample code snippet that demonstrates how to do it. How to Perform Inner Join using LINQ in C# ? Assume that the 2 objects that needs to be joined are Employee and EmployeeLeave as shown below. The employees and the leaves list contains the…
How to Create Pivot Data using LINQ in C#?
Are you looking forward to create a pivot data using LINQ in C#, here we go. How to Create Pivot Data using LINQ in C#? Below is a sample code snippet that demonstrates the creation of the Pivot Data using LINQ and C#?
Example of deferred execution of LINQ Query in C# .NET
Below is a sample code snippet that demonstrates the deferred execution of LINQ Query in C#. Example of deferred execution of LINQ Query in C# .NET The Output of the above program is
Rules for using Anonymous Types in C#
The anonymous types (var) in C# is an interesting feature that the C# developers could use within their .NET application . When using the anonymous type , there are certain criteria or rules that needs to be followed . Rules for using Anonymous Types in C# Below are some of the rules that the developers should be following when using the anonymous type. 1. NULL…
How to Get the Last Element from LINQ Query in C#?
Below is a sample source code demonstrating How to Get the Last Element from LINQ Query in C#? How to Get the Last Element from LINQ Query in C#?
How to Remove Objects from the List with RemoveAll in C#?
Below is a sample code snippet demonstrating How to Remove Objects from the List with RemoveAll in C#? How to Remove Objects from the List with RemoveAll in C#?
How to select top 5 records from List using LINQ in C#?
Below is a sample code snippet demonstrating on how to select top 5 records from a list using LINQ in C# using the Take extension method… How to select top 5 records from List using LINQ in C#?
Best Java Equivalent for LINQ (C#)
LINQ Query and Lambda expressions are one of the popular features of C# which helped the .NET developers in many ways. If you are a Java developer and wondering is there anything similar to this in Java ? ,this post will provide some insights on the additional APIs which could bring in the similar functionality Best Java Equivalent for LINQ (C#) jaque Another Java integrated…
C# and LINQ – Filter elements from object collection using where clause
Here’s a sample code snippet demonstrating how to filter elements from a list of objects using the where clause using LINQ in C#. This sample gets all the employees who salary is greater than 20000 GBP. How to Filter Employees List whose salary is greater than 20000 GBP using LINQ in C# ? Output Employees whose salary is greater than 20000 pounds Michael John
How to Use LINQ query on a DataTable in C#?
Below is a sample code snippet that demonstrates the usage of the LINQ query on a DataTable in C#. How to Use LINQ query on a DataTable in C#?
How to Get the Maximum value from a List of String using LINQ in C# ?
In one of the previous article , we explained how to get the maximum value from a list of integer using LINQ query in C# . What happens when the column is a string instead of integer ?. Below are 2 possibilities on how to get the maximum value from a list of string. How to Get the Maximum value from a List of String…
How to Convert DBContext Object to ObjectContext in C# ?
Below is a function that converts the DBContext object to ObjectContext in C#. How to Convert DBContext Object to ObjectContext in C# ?
LINQ to Objects Query against a Collection of Objects
Below is a sample code snippet that demonstrates how to use the LINQ Query to query against the LINQ to Objects. LINQ to Objects Query against a Collection of Objects
How to Get the First Element from LINQ Query in C#?
Below is a sample source code demonstrating How to Get the First Element from LINQ Query in C#? How to Get the First Element from LINQ Query in C#?