public CustomerSpecial GetCustomersByCustomerIdentifierSqlClientDataProvider(int pCustomerIdentifier) { DatabaseServer = ".\\SQLEXPRESS"; DefaultCatalog = "NorthWindAzureForInserts"; var statements = new SelectStatements(); var customer = new CustomerSpecial() { Customer = new Customer() { Country = new Country(), CustomerIdentifier = pCustomerIdentifier, Contact = new Contact() }, Contact = new Contact() }; using (var cn = new SqlConnection { ConnectionString = ConnectionString }) { using (var cmd = new SqlCommand { Connection = cn }) { cmd.CommandText = statements.SelectCustomerByCustomerIdentifier; cmd.Parameters.AddWithValue("@CustomerIdentifier", pCustomerIdentifier); try { cn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); customer.Customer.CompanyName = reader.GetString(1); customer.Customer.ContactId = reader.GetInt32(2); customer.Customer.Contact.FirstName = reader.GetString(3); customer.Customer.Contact.LastName = reader.GetString(4); customer.Contact.Title = reader.GetString(5); customer.Customer.Contact.Title = reader.GetString(5); customer.Customer.CountryIdentifier = reader.GetInt32(6); customer.Customer.Country.CountryIdentifier = reader.GetInt32(6); customer.Customer.Country.Name = reader.GetString(7); } } catch (Exception e) { mHasException = true; mLastException = e; throw; } } } return(customer); }
public override void Visit(SelectStatement node) { SelectStatements.Add(node); }
public override void ExplicitVisit(SelectStatement node) { SelectStatements.Add(node); base.ExplicitVisit(node); }