try
{
}
catch
{
// I'm catching everything as I don't really
// know what my application is doing.
}// No estoy seguro si se usará todavía
// int result = command.Setup();
// Command.WriteLine(result)SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM Tabla WHERE Campo = @param"; command.Parameters.Add(new SqlCommand(SqlDbType.String, "prueba"); var reader = command.ExecuteReader();... // Etc...
var db = new sistemaContext();
var ordenes = db.Ordenes.Where(order => order.Id == 45); public void DoSomething(string param){//Create dbContextvar context = new MyDbContext();//Get Customersvar customers = context.Customers.ToList();//Update Customerscustomers.ForEach(c => c.PropertyX == param);//Save Changescontext.SaveChanges();}
private void button1_click(object sender, EventArgs e)
{
//Save Customer Info
txtName.Text = "";
txtAddress.Text = "";
//After Refactor, just one line of code
RefreshAndClearControls();
}
private void button2_click(object sender, EventArgs e)
{
txtName.Text = "";
txtAddress.Text = "";
//After refactor
RefreshAndClearControls();
}
private void RefreshAndClearControls()
{
txtName.Text = "";
txtAddress.Text = "";
}
public void DoSomething(int customerID) { var customer = context.Customers.FirstOrDefault(c => c.CustomerID == customerID);var newCustomer = new Customer(); newCustomer.Name = customer.Name;// el objeto customer puede estar nulo si el id // del usuario no existe}
public List<Cliente> GetClientesPorCategory(string categoria){}
