c# linq query code example
Example 1: c# mysql query
MySqlConnection con = new MySqlConnection(connectionString);
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM customers",con);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["customerName"].ToString());
Console.WriteLine(reader.GetInt32(0));
}
con.Close();
Example 2: linq query select where c#
var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;
Example 3: C# linq mselect
var users = new List<Users>()
var names = users.Select(xx=> xx.Name);