In SQL we have the requirement to filter the results based on a maximum or a minimum value.We use the top operator in SQL server to filter the top results based on a criteria. We can achieve similar functionality in LINQ using the Take() and TakeWhile() extension methods.Take extension method returns the specified number of elements.TakeWhile […]
Archives for March 2016
Convert Comma Separated Values to Rows in SQL server
A common requirement is to convert rows from CSV values.If we have string such as ‘ORANGES,APPLES,BANANAS’ then we can create a result set from these values. ORANGES APPLES BANANAS Here we will see how to do it using a custom SQL Server function.But before that it will be helpful if we understand some of the useful […]
Joins in LINQ
Join clause in LINQ is used when we have multiple data sources and we want to match the elements in those data sources based on some common property.For example we can have two Lists and we want to associate every element in the first list with the elements in the second list. In the following example […]
Functional Construction in LINQ to XML
We can create XML without using LINQ to XML by directly using the XmlDocument and the related classes. When we create XML using this approach we are manipulating the XML document.It is also not very easy to understand the XML manipulation logic.We can not tell by just looking at the code the XML tree being created. For […]
Creating XML using LINQ to XML
The classes required for the LINQ to XML functionality are part of the System.Xml.Linq namespace.So if we want to implement LINQ to XML then we need to use the classes defined in the System.Xml.Linq namespace. Some of the important classes required to create an XML document are: XElement It represents an element in the XML. […]