Answers for "select linq c#"

SQL
3

c# sql select

SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=");
conn.Open();

SqlCommand command = new SqlCommand("Select id from [table1] where name=@zip", conn);
command.Parameters.AddWithValue("@zip","india");
 // int result = command.ExecuteNonQuery();
using (SqlDataReader reader = command.ExecuteReader())
{
  if (reader.Read())
  {
     Console.WriteLine(String.Format("{0}",reader["id"]));
   }
}

conn.Close();
Posted by: Guest on January-08-2021
1

linq query select where c#

var queryLondonCustomers = from cust in customers
                           where cust.City == "London"
                           select cust;
Posted by: Guest on November-05-2020
1

c# linq list select

List<Model> newList = list.Where(m => m.application == "applicationname")
    .Select(m => new Model { 
        application = m.application, 
        users = m.users.Where(u => u.surname == "surname").ToList() 
    }).ToList();
Posted by: Guest on February-01-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language