public void Concat90() { using (var context = new TestDbManager()) { var join1 = from t1 in context.GetTable <TestEntity1>() join t2 in context.GetTable <TestEntity2>() on t1.Id equals t2.Id into tmp from t2 in tmp.DefaultIfEmpty() select new { t1, t2 }; var join1Sql = join1.ToString(); Assert.IsNotNull(join1Sql); var join2 = from t2 in context.GetTable <TestEntity2>() join t1 in context.GetTable <TestEntity1>() on t2.Id equals t1.Id into tmp from t1 in tmp.DefaultIfEmpty() where t1 == null select new { t1, t2 }; var join2Sql = join2.ToString(); Assert.IsNotNull(join2Sql); var fullJoin = join1.Concat(join2); var fullJoinSql = fullJoin.ToString(); // BLToolkit.Data.Linq.LinqException : Types in Concat are constructed incompatibly. Assert.IsNotNull(fullJoinSql); } }
//[Test] public void BoolTest2() { List <PersonBoolTest> list; using (var db = new TestDbManager()) list = db.GetTable <PersonBoolTest>().ToList(); ForEachProvider(db => AreEqual( from p in list where p.IsMale == true select p.PersonID, from p in db.GetTable <PersonBoolTest>() where p.IsMale == true select p.PersonID)); }
public void CharTest2() { List <PersonCharTest> list; using (var db = new TestDbManager()) list = db.GetTable <PersonCharTest>().ToList(); ForEachProvider(db => AreEqual( from p in list where 'M' == p.Gender select p.PersonID, from p in db.GetTable <PersonCharTest>() where 'M' == p.Gender select p.PersonID)); }
public void IEnumerableTest2() { using (var db = new TestDbManager()) { var zones = from z in db.GetTable <TestEntity2>() join o in db.GetTable <SuperAccount>() on z.Owner.Id equals o.Id select z; zones.ToList(); } }
public void IEnumerableTest1() { using (var db = new TestDbManager()) { var res = from rc in db.GetTable <TestEntity>() join li in db.GetTable <LookupEntity>() on rc.Id equals li.InnerEnity.Id where rc.EntityType == TestEntityType.Type1 select rc; res.ToList(); } }
public void ExplicitInterface3() { using (var db = new TestDbManager()) { var result = SelectNoDate2(db.GetTable <TestTable3>()).ToList(); } }
public void ContractLinqManyInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable <User>().Insert(db.GetTable <Contract>(), x => new Contract { UserId = x.Id, ContractNo = 1, Name = "contract" }); } }
public void GuidTest() { using (var db = new TestDbManager()) { var list = db.GetTable <InheritanceA>().Where(a => a.Bs.Any()).ToList(); } }
public void UserLinqInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.GetTable<User>().Insert(() => new User { Name = "user" }); } }
public void UserLinqInsert() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.GetTable<User>().Insert(() => new User { Name = "user" }); } }
public void MyType1() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { var list = db.GetTable <MyParent>().ToList(); } }
public void AllNames() { using (var db = new TestDbManager("Sql2008")) db.GetTable<ParenTable>() .DatabaseName("BLToolkitData") .OwnerName("dbo") .TableName("Parent") .ToList(); }
public void AllNames([IncludeDataContexts("Sql2008")] string context) { using (var db = new TestDbManager(context)) db.GetTable<ParenTable>() .DatabaseName("TestData") .OwnerName("dbo") .TableName("Parent") .ToList(); }
public void AllNames([IncludeDataContexts("Sql2008")] string context) { using (var db = new TestDbManager(context)) db.GetTable<ParenTable>() .DatabaseName("BLToolkitData") .OwnerName("dbo") .TableName("Parent") .ToList(); }
public void AllNames() { using (var db = new TestDbManager("Sql2008")) db.GetTable <ParenTable>() .DatabaseName("BLToolkitData") .OwnerName("dbo") .TableName("Parent") .ToList(); }
public void UserLinqInsert() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.GetTable <User>().Insert(() => new User { Name = "user" }); } }
public void UserLinqInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.GetTable <User>().Insert(() => new User { Name = "user" }); } }
public void MapAbstract() { using (var db = new TestDbManager()) { var q = from a in db.GetTable <AbsChild>() select new { a.ChildID, a.Parent.Value1 }; var ql = q.ToList(); } }
public void TestMethod() { using (var db = new TestDbManager()) { IQueryable <IDocument> query = db.GetTable <Document>(); var idsQuery = query.Select(s => s.Id); var str = idsQuery.ToString(); // Exception Assert.IsNotNull(str); } }
public void InheritanceMappingIssueTest() { using (var db = new TestDbManager()) { var q1 = db.GetTable <Parent222>(); var q = q1.Where(_ => _.Value.ID == 1); var sql = ((Table <Parent222>)q).SqlText; Assert.IsNotEmpty(sql); } }
public void MyType2() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { var list = db.GetTable <MyParent>() .Select(t => new MyParent { ParentID = t.ParentID, Value1 = t.Value1 }) .ToList(); } }
public void SelectField() { using (var db = new TestDbManager()) { var q = from p in db.GetTable <TestParent>() select p.Value1_; var sql = q.ToString(); Assert.That(sql.IndexOf("ParentID_"), Is.LessThan(0)); } }
public void IsDbGeneratedTest() { using (var db = new TestDbManager("Sql2008")) { var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id)); } }
public void IsDbGeneratedTest() { using (var db = new TestDbManager("Sql2008")) { var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable <L2SPersons>().Delete(p => p.PersonID == ConvertTo <int> .From(id)); } }
public void ContractLinqInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable <Contract>().InsertWithIdentity(() => new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
public void IsDbGeneratedTest([IncludeDataContexts("Sql2008", "Sql2012")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id)); } }
public void IsDbGeneratedTest([IncludeDataContexts("Sql2008", "Sql2012")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable <L2SPersons>().Delete(p => p.PersonID == ConvertTo <int> .From(id)); } }
//[Test] public void ContractLinqManyInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable<User>().InsertWithIdentity(db.GetTable<Contract>(), x => new Contract { UserId = x.Id, ContractNo = 1, Name = "contract" }); } }
public void DatabaseName([IncludeDataContexts("Sql2008")] string context) { using (var db = new TestDbManager(context)) db.GetTable<Parent>().DatabaseName("BLToolkitData").ToList(); }
public void MapAbstract() { using (var db = new TestDbManager()) { var q = from a in db.GetTable<AbsChild>() select new { a.ChildID, a.Parent.Value1 }; var ql = q.ToList(); } }
public void OwnerName([IncludeDataContexts("Sql2008", "Sql2012")] string context) { using (var db = new TestDbManager(context)) db.GetTable<Parent>().OwnerName("dbo").ToList(); }
public void OwnerName() { using (var db = new TestDbManager("Sql2008")) db.GetTable <Parent>().OwnerName("dbo").ToList(); }
public void MyType1() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { var list = db.GetTable<MyParent>().ToList(); } }
public void DatabaseName([IncludeDataContexts("Sql2008")] string context) { using (var db = new TestDbManager(context)) db.GetTable<Parent>().DatabaseName("TestData").ToList(); }
public void TableName() { using (var db = new TestDbManager("Sql2008")) db.GetTable <ParenTable>().TableName("Parent").ToList(); }
public void NoTransactionWithIdentity2([DataContexts(ExcludeLinqService = true)] string context) { using (var db = new TestDbManager(context)) { try { var list = new[] { new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, }; db.GetTable<Table2>().Delete(_ => _.IntValue == 1111); var c1 = db.GetTable<Table2>().Count(); db.InsertBatch(list); var c2 = db.GetTable<Table2>().Count(); Assert.AreEqual(c1+4, c2); var result = db.GetTable<Table2>().Where(_ => _.IntValue == 1111).ToList(); foreach (var e in result) { Assert.AreEqual(1111, e.Object.Value); } } finally { db.GetTable<Table2>().Delete(_ => _.IntValue == 1111); } } }
public void ContractLinqInsertWithIdentity([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable<Contract>().InsertWithIdentity(() => new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
public void SimplTest() { using (var db = new TestDbManager()) Assert.AreEqual(1, db.GetTable <PersonEx>().Where(_ => _.FirstName == "John").Select(_ => _.ID).Single()); }
public void TransactionWithIdentity1([DataContexts(ExcludeLinqService = true)] string context) { using (var db = new TestDbManager(context)) { try { var list = new[] { new Table {IntValue = 1111, StringValue = "1111"}, new Table {IntValue = 2111, StringValue = "2111"}, new Table {IntValue = 3111, StringValue = "3111"}, new Table {IntValue = 4111, StringValue = "4111"}, }; db.GetTable<Table>().Delete(_ => _.Id > 2); var c1 = db.GetTable<Table>().Count(); db.BeginTransaction(); db.InsertBatch(list); db.CommitTransaction(); var c2 = db.GetTable<Table>().Count(); Assert.AreEqual(c1+4, c2); } finally { db.GetTable<Table>().Delete(_ => _.Id > 2); } } }
public void Concat90() { using(var context = new TestDbManager()) { var join1 = from t1 in context.GetTable<TestEntity1>() join t2 in context.GetTable<TestEntity2>() on t1.Id equals t2.Id into tmp from t2 in tmp.DefaultIfEmpty() select new { t1, t2 }; var join1Sql = join1.ToString(); Assert.IsNotNull(join1Sql); var join2 = from t2 in context.GetTable<TestEntity2>() join t1 in context.GetTable<TestEntity1>() on t2.Id equals t1.Id into tmp from t1 in tmp.DefaultIfEmpty() where t1 == null select new { t1, t2 }; var join2Sql = join2.ToString(); Assert.IsNotNull(join2Sql); var fullJoin = join1.Concat(join2); var fullJoinSql = fullJoin.ToString(); // BLToolkit.Data.Linq.LinqException : Types in Concat are constructed incompatibly. Assert.IsNotNull(fullJoinSql); } }
public void CharTest2() { List<PersonCharTest> list; using (var db = new TestDbManager()) list = db.GetTable<PersonCharTest>().ToList(); ForEachProvider(db => AreEqual( from p in list where 'M' == p.Gender select p.PersonID, from p in db.GetTable<PersonCharTest>() where 'M' == p.Gender select p.PersonID)); }
//[Test] public void BoolTest2() { List<PersonBoolTest> list; using (var db = new TestDbManager()) list = db.GetTable<PersonBoolTest>().ToList(); ForEachProvider(db => AreEqual( from p in list where p.IsMale == true select p.PersonID, from p in db.GetTable<PersonBoolTest>() where p.IsMale == true select p.PersonID)); }
public void OwnerName() { using (var db = new TestDbManager("Sql2008")) db.GetTable<Parent>().OwnerName("dbo").ToList(); }
public void DatabaseName() { using (var db = new TestDbManager("Sql2008")) db.GetTable <Parent>().DatabaseName("BLToolkitData").ToList(); }
public void DatabaseName() { using (var db = new TestDbManager("Sql2008")) db.GetTable<Parent>().DatabaseName("BLToolkitData").ToList(); }
public void InheritanceMappingIssueTest() { using (var db = new TestDbManager()) { var q1 = db.GetTable<Parent222>(); var q = q1.Where(_ => _.Value.ID == 1); var sql = ((Table<Parent222>)q).SqlText; Assert.IsNotEmpty(sql); } }
public void TableName() { using (var db = new TestDbManager("Sql2008")) db.GetTable<ParenTable>().TableName("Parent").ToList(); }
public void MyType2() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { var list = db.GetTable<MyParent>() .Select(t => new MyParent { ParentID = t.ParentID, Value1 = t.Value1 }) .ToList(); } }
public void SimplTest() { using (var db = new TestDbManager()) Assert.AreEqual(1, db.GetTable<PersonEx>().Where(_ => _.FirstName == "John").Select(_ => _.ID).Single()); }
public void TestMethod() { using (var db = new TestDbManager()) { IQueryable<IDocument> query = db.GetTable<Document>(); var idsQuery = query.Select(s => s.Id); var str = idsQuery.ToString(); // Exception Assert.IsNotNull(str); } }
public void SelectField() { using (var db = new TestDbManager()) { var q = from p in db.GetTable<TestParent>() select p.Value1_; var sql = q.ToString(); Assert.That(sql.IndexOf("ParentID_"), Is.LessThan(0)); } }