public void Test() { using (AdventureWorksDataSession session = new AdventureWorksDataSession()) { var results = session.FetchAll((Person c) => new { UserFirstName = c.FirstName, UserLastName = c.LastName }); Assert.IsNotNull(results); } }
public void ToList() { using (AdventureWorksDataSession session = new AdventureWorksDataSession("adventureWorks")) { List <Person> contacts = session.Persons.ToList(Person.Columns.BusinessEntityId > 1000); Assert.IsTrue(contacts.Count > 0); Assert.IsTrue(contacts[0].BusinessEntityId > 1000); } }
public void Test() { using (AdventureWorksDataSession session = new AdventureWorksDataSession("adventureWorks")) { Person[] contacts = session.Persons.ToArray(Person.Columns.BusinessEntityId.IsBetween(1000, 1020)); var converted = session.Persons.ToArray(Person.Columns.BusinessEntityId.IsBetween(1000, 1020), c => new { Name = c.FirstName + " " + c.LastName }); Assert.IsTrue(converted.Length > 0); Assert.IsTrue(converted.Length <= 20); Assert.IsNotNull(converted[0].Name); Assert.AreEqual(contacts[0].FirstName + " " + contacts[0].LastName, converted[0].Name); } }
public void ToArray() { using (AdventureWorksDataSession session = new AdventureWorksDataSession("adventureWorks")) { ThreadedRepeat(1, session, (index, asserter, state) => { Person[] contacts = state.Persons.ToArray(Person.Columns.BusinessEntityId > 1000); Assert.IsTrue(contacts.Length > 0); Assert.IsTrue(contacts[0].BusinessEntityId > 1000); }); } }
public void AutoJoinReverseTableOrderThreaded() { const string expected = "SELECT * FROM [HumanResources].[Employee] _t0, [Person].[Person] _t1 " + "WHERE _t0.[BusinessEntityID] = _t1.[BusinessEntityID] " + "AND _t0.[HireDate] = @_p0 " + "AND _t1.[FirstName] = @_p1"; const string expected2 = "SELECT * FROM [Person].[Person] _t0, [HumanResources].[Employee] _t1 " + "WHERE _t0.[BusinessEntityID] = _t1.[BusinessEntityID] " + "AND _t1.[HireDate] = @_p0 " + "AND _t0.[FirstName] = @_p1"; const string expected3 = "SELECT * FROM [HumanResources].[Employee] _t0 " + "WHERE _t0.[HireDate] = @_p0"; ThreadedRepeat(500, (index, threadAsserter) => { AdventureWorksDataSession session = new AdventureWorksDataSession("adventureWorks"); EntitySet <Employee> query = session.Employees; query.Where(Employee.Columns.HireDate == DateTime.Now); query.Where(Person.Columns.FirstName == "John"); DbCommand command = query.CreateCommand(); EntitySet <Person> query2 = session.Persons; query2.Where(Employee.Columns.HireDate == DateTime.Now); query2.Where(Person.Columns.FirstName == "John"); DbCommand command2 = query2.CreateCommand(); EntitySet <Employee> query3 = session.Employees; query3.Where(Employee.Columns.HireDate == DateTime.Now); DbCommand command3 = query3.CreateCommand(); threadAsserter.RegisterDependency(session); threadAsserter.Assert(() => AssertCommandTextSame(expected, command)); threadAsserter.Assert(() => AssertParamCountSame(command, 2)); threadAsserter.Assert(() => AssertCommandTextSame(expected2, command2)); threadAsserter.Assert(() => AssertParamCountSame(command2, 2)); threadAsserter.Assert(() => AssertCommandTextSame(expected3, command3)); threadAsserter.Assert(() => AssertParamCountSame(command3, 1)); }); }
public void DeleteByKeys() { using (AdventureWorksDataSession session = new AdventureWorksDataSession("adventureWorks")) using (TransactionScope scope = new TransactionScope()) { } }
public void Initialize() { Session = new AdventureWorksDataSession(); }