Monthly Archives: May 2010

Types of LINQ

LINQ to Objects: Provides queries on any kind of C# in-memory object, such as arrays, lists, and other collection types. LINQ to XML: Provides creation and manipulation of XML documents using the same syntax and general query mechanism as the … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Join Query in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQJoinQuery { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged , | Leave a comment

Set operators in LINQ

LINQ provides standard set operators such as Union() and Intersect() that operate on query results. using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQSetOperators { class Customer { public string ID { get; set; } public string City … Continue reading

Posted in C# ASP.NET LINQ | Tagged , | Leave a comment

Using First and FirstOrDefault in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQFirstOrDefault { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Example of Take and Skip in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQTakeAndSkip { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Using a Group Query in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace GroupQuery { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged , , | Leave a comment

Ordering By Multiple Levels in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace MultiLevelOrdering { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Using Any and All in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQAnyAndAll { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Select Distinct Query in LINQ Projection

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQSelectDistinct { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged , | Leave a comment

Creating New Objects in Queries using LINQ Projection

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace ProjectionCreateNewObjects { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged , , | Leave a comment

Querying Complex Objects in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace QueryComplexObjects { class Customer { public string ID { get; set; } public string City { get; set; } public string Country { get; set; } public string Region { … Continue reading

Posted in C# ASP.NET LINQ | Tagged , | Leave a comment

Example of Numeric Aggregates in LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace NumericAggregates { class Program { static void Main(string[] args) {   int[] numbers = CreateNumbers(12345678);   Console.WriteLine("Numeric Aggregates example in linq");   var queryResults = from n in numbers where … Continue reading

Posted in C# ASP.NET LINQ | Tagged , , | Leave a comment

Aggregate operators in LINQ

Count() Count of results Min() Minimum value in results Max() Maximum value in results Average() Average value of numeric results Sum() Total of all of numeric results

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Querying a Large Data Set using LINQ

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LargeNumberQuery { class Program { static void Main(string[] args) { int[] numbers = CreateNumbers(7384738);   Console.WriteLine("Numbers less than 2000:");   var queryResults = from n in numbers where n < … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

LINQ OrderBy in Query Syntax

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace OrderQueryResults { class Program { static void Main(string[] args) { string[] names = {"kaka", "kunka", "kumar", "James", "Smith"};   var queryResults = from n in names where n.StartsWith("k") orderby n … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Use LINQ to find names starting with specific alphabet and method syntax

using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace LINQMethodSyntax { class Program { static void Main(string[] args) { string[] names = { "kaka", "kunka", "kumar", "James", "Smith"};   var queryResults = names.Where(n => n.StartsWith("k"));   Console.WriteLine("Names beginning with … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Use LINQ to find names starting with specific alphabet and query syntax

Example to use LINQ to find names starting with a specific alphabet (k). using System; using System.Collections.Generic; using System.Linq; using System.Text;   static void Main(string[] args) { string[] names = { "kaka", "kunka", "kumar", "James", "Smith"}; var queryResults = from … Continue reading

Posted in C# ASP.NET LINQ | Tagged | Leave a comment

Join two MySQL tables together

SELECT a.column1, b.column1, b.column2 FROM tablename a JOIN tablename b ON a.column1 = b.column1 WHERE a.column1 LIKE ‘%something%’

Posted in MYSQL Basics | Tagged | Leave a comment

Using MySQL SELECT to count rows in a table

MySQL count() Returns a count of the total number of rows in a table. SELECT COUNT(*) from TableName

Posted in MYSQL Basics | Tagged | Leave a comment

Using MySQL SELECT to return first 10 rows

To return the first 10 rows we should run a SQL Select statement and limit the number of rows returned. This is useful when we only want to return a few rows to do some initial analysis. SELECT column1, column2, … Continue reading

Posted in MYSQL Basics | Tagged | Leave a comment