public void ShouldReleaseDatasetAfterSelect() { var sut = new SqlServerConnection("Data Source=.;Initial Catalog=DbSessionTests;Integrated Security=True;"); var result = sut.Select( "SELECT * FROM TestTable WHERE Id IN (@Id1, @Id2)", new ParameterSet { new Parameter <int>("Id1", 1), new Parameter <int>("Id2", 2) }); var result2 = sut.Select( "SELECT * FROM TestTable WHERE Id IN (@Id1, @Id2)", new ParameterSet { new Parameter <int>("Id1", 1), new Parameter <int>("Id2", 2) }); Assert.That(result.Count(), Is.EqualTo(2)); Assert.That(result2.Count(), Is.EqualTo(2)); }
private void Form1_Load(object sender, EventArgs e) { try { txtMa.Enabled = false; connection.Open(); cellphones = connection.ExecuteQuery <CellPhone>("Select * From CellPhone"); makers = connection.Select <Maker>().Rows().Execute(); colors = connection.Select <Color>().Rows().Execute(); BindingGrigViewCellPhone(cellphones); AddDataMakerToComboBox(makers); connection.Close(); } catch (Exception err) { MessageBox.Show(err.Message); } }
public void ShouldSelect() { var sut = new SqlServerConnection("Data Source=.;Initial Catalog=DbSessionTests;Integrated Security=True;"); var result = sut.Select( "SELECT * FROM TestTable WHERE Id IN (@Id1, @Id2)", new ParameterSet { new Parameter <int>("Id1", 1), new Parameter <int>("Id2", 2) }).ToList(); Assert.That(result.Count, Is.EqualTo(2)); Assert.That(result[0]["Id"], Is.EqualTo(1)); Assert.That(result[0]["TestValue"], Is.EqualTo(5)); Assert.That(result[1]["Id"], Is.EqualTo(2)); Assert.That(result[1]["TestValue"], Is.EqualTo(6)); }