public void Any() { Guid TempGuid = Guid.NewGuid(); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Temp.AddCommand(null, null, "insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", "Test String", 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid) .Execute(); bool Found = false; dynamic Item = Utilities.ORM.QueryProvider.Any("SELECT * FROM TestTable", CommandType.Text, TestDatabaseSource.Name); if (Item != null) { Assert.Equal("Test String", Item.StringValue1); Assert.Equal("Test String", Item.StringValue2); Assert.Equal(12345, Item.BigIntValue); Assert.Equal(true, Item.BitValue); Assert.Equal(1234.5678m, Item.DecimalValue); Assert.Equal(12345.6534f, Item.FloatValue); Assert.Equal(TempGuid, Item.GUIDValue); Assert.Equal(new DateTime(1999, 12, 31), Item.DateTimeValue); Found = true; } if (!Found) { Assert.False(true, "Nothing was inserted"); } }
public void AddCommand() { var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Temp.AddCommand(null, null, "SELECT * FROM A", CommandType.Text, "@", new object[] { 1, "ASDF", 2.0f, Guid.NewGuid() }); Assert.Equal(1, Temp.CommandCount); }
public void MBDBug() { var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(MasterDatabaseSource); int DbID = Temp.AddCommand(null, null, "SELECT database_id FROM Master.sys.Databases WHERE name=@0", CommandType.Text, "TestDatabase") .Execute() .First() .First() .database_id; Assert.True(DbID > 0); }
public virtual void Dispose() { var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(MasterDatabaseSource); try { Temp.AddCommand(null, null, CommandType.Text, "ALTER DATABASE TestDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE") .AddCommand(null, null, CommandType.Text, "ALTER DATABASE TestDatabase SET ONLINE") .AddCommand(null, null, CommandType.Text, "DROP DATABASE TestDatabase") .Execute(); } catch { } }
public void Insert() { var TempGuid = Guid.NewGuid(); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Temp.AddCommand(null, null, "insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", "Test String", 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid) .Execute(); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); bool Found = false; foreach (dynamic Item in Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestTable") .Execute() .First()) { Assert.Equal("Test String", Item.StringValue1); Assert.Equal("Test String", Item.StringValue2); Assert.Equal(12345, Item.BigIntValue); Assert.Equal(true, Item.BitValue); Assert.Equal(1234.5678m, Item.DecimalValue); Assert.Equal(12345.6534f, Item.FloatValue); Assert.Equal(TempGuid, Item.GUIDValue); Assert.Equal(new DateTime(1999, 12, 31), Item.DateTimeValue); Found = true; } if (!Found) { Assert.False(true, "Nothing was inserted"); } Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Found = false; foreach (dynamic Item in Temp.AddCommand(null, null, CommandType.Text, "SELECT COUNT(*) as [ItemCount] FROM TestTable") .Execute() .First()) { Assert.Equal(1, Item.ItemCount); Found = true; } if (!Found) { Assert.False(true, "Nothing was inserted"); } }
public override void Dispose() { base.Dispose(); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(MasterDatabaseSource); try { Temp.AddCommand(null, null, CommandType.Text, "ALTER DATABASE SessionWithAbstractClassTestDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE") .AddCommand(null, null, CommandType.Text, "ALTER DATABASE SessionWithAbstractClassTestDatabase SET ONLINE") .AddCommand(null, null, CommandType.Text, "DROP DATABASE SessionWithAbstractClassTestDatabase") .Execute(); } catch { } }
protected DatabaseBaseClass() : base() { DatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(new List<IDatabase>()).GetSource("Data Source=localhost;Integrated Security=SSPI;Pooling=false"); LDAPSource = new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll<IDatabase>()).GetSource("LDAP"); MasterDatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(new List<IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;Pooling=false"); TestDatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll<IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(DatabaseSource); try { Temp.AddCommand(null, null, CommandType.Text, "Create Database TestDatabase") .Execute(); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Temp.AddCommand(null, null, CommandType.Text, "Create Table TestTable(ID INT PRIMARY KEY IDENTITY,StringValue1 NVARCHAR(100),StringValue2 NVARCHAR(MAX),BigIntValue BIGINT,BitValue BIT,DecimalValue DECIMAL(12,6),FloatValue FLOAT,DateTimeValue DATETIME,GUIDValue UNIQUEIDENTIFIER)") .Execute(); } catch { } }
protected DatabaseBaseClass() { DatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(new List <IDatabase>()).GetSource("Data Source=localhost;Integrated Security=SSPI;Pooling=false"); LDAPSource = new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("LDAP"); MasterDatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(new List <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;Pooling=false"); TestDatabaseSource = new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(DatabaseSource); try { Temp.AddCommand(null, null, CommandType.Text, "Create Database TestDatabase") .Execute(); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); Temp.AddCommand(null, null, CommandType.Text, "Create Table TestTable(ID INT PRIMARY KEY IDENTITY,StringValue1 NVARCHAR(100),StringValue2 NVARCHAR(MAX),BigIntValue BIGINT,BitValue BIT,DecimalValue DECIMAL(12,6),FloatValue FLOAT,DateTimeValue DATETIME,GUIDValue UNIQUEIDENTIFIER)") .Execute(); } catch { } }
public void LargeBatchInsert() { var TempGuid = Guid.NewGuid(); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); for (int x = 0; x < 1000; ++x) { Temp.AddCommand(null, null, "insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", "Test String", 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid); } Temp.Execute(); }
public void UpdateCascade() { var TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); var TempObject = new TestClass(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.ManyToManyIEnumerable = new TestClass[] { new TestClass(), new TestClass() }; TempObject.ManyToManyList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneIEnumerable = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }; TempObject.ManyToOneItem = new TestClass(); TempObject.ManyToOneList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneIList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToManyIList = new TestClass[] { new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneICollection = new TestClass[] { new TestClass(), new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToManyICollection = new TestClass[] { new TestClass() }.ToList(); TempObject.Map = new TestClass(); TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestClass, int>(TempObject); Assert.Equal(true, TempObject.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, TempObject.ByteArrayReference); Assert.Equal(12, TempObject.ByteReference); Assert.Equal('v', TempObject.CharReference); Assert.Equal(1.4213m, TempObject.DecimalReference); Assert.Equal(1.32645d, TempObject.DoubleReference); Assert.Equal(TestEnum.Value2, TempObject.EnumReference); Assert.Equal(1234.5f, TempObject.FloatReference); Assert.Equal(TempGuid, TempObject.GuidReference); Assert.Equal(145145, TempObject.IntReference); Assert.Equal(763421, TempObject.LongReference); Assert.Equal(2, TempObject.ManyToManyIEnumerable.Count()); Assert.Equal(3, TempObject.ManyToManyList.Count); Assert.Equal(3, TempObject.ManyToOneIEnumerable.Count()); Assert.NotNull(TempObject.ManyToOneItem); Assert.Equal(3, TempObject.ManyToOneList.Count); Assert.Equal(3, TempObject.ManyToOneIList.Count); Assert.Equal(2, TempObject.ManyToManyIList.Count); Assert.Equal(4, TempObject.ManyToOneICollection.Count); Assert.Equal(1, TempObject.ManyToManyICollection.Count); Assert.NotNull(TempObject.Map); Assert.Equal(null, TempObject.NullStringReference); Assert.Equal(5423, TempObject.ShortReference); Assert.Equal("agsdpghasdg", TempObject.StringReference); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionTestDatabase;Integrated Security=SSPI;Pooling=false")); var Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestClass_").Execute().First(); TestClass Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); Item.Map = new TestClass { FloatReference = 10f }; Item.ManyToManyIEnumerable.First().FloatReference = 11f; Item.ManyToManyList.Add(new TestClass { FloatReference = 12f }); Item.ManyToOneIEnumerable.First().FloatReference = 13f; Item.ManyToOneItem.FloatReference = 14f; Item.ManyToOneList = new TestClass[] { new TestClass(), new TestClass() }.ToList(); Item.ManyToManyIList.Add(new TestClass { FloatReference = 15f }); Item.ManyToOneIList.Add(new TestClass { FloatReference = 16f }); Item.ManyToManyICollection.Add(new TestClass { FloatReference = 17f }); Item.ManyToOneICollection.Add(new TestClass { FloatReference = 18f }); TestObject.Save <TestClass, int>(Item); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionTestDatabase;Integrated Security=SSPI;Pooling=false")); Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestClass_").Execute().First(); Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(10, Item.Map.FloatReference); Assert.Equal(11f, Item.ManyToManyIEnumerable.First().FloatReference); Assert.Equal(12f, Item.ManyToManyList.Last().FloatReference); Assert.Equal(13f, Item.ManyToOneIEnumerable.First().FloatReference); Assert.Equal(14f, Item.ManyToOneItem.FloatReference); Assert.Equal(15f, Item.ManyToManyIList.Last().FloatReference); Assert.Equal(16f, Item.ManyToOneIList.Last().FloatReference); Assert.Equal(17f, Item.ManyToManyICollection.Last().FloatReference); Assert.Equal(18f, Item.ManyToOneICollection.Last().FloatReference); Assert.Equal(2, Item.ManyToOneList.Count); }
public void Update() { Guid TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); var TempObject = new TestClass2(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.ManyToManyIEnumerable = new TestClass2[] { new TestClass2(), new TestClass2() }; TempObject.ManyToManyList = new TestAbstractClass[] { new TestClass2(), new TestClass2(), new TestClass2() }.ToList(); TempObject.ManyToOneIEnumerable = new TestClass2[] { new TestClass2(), new TestClass2(), new TestClass2() }; TempObject.ManyToOneItem = new TestClass2(); TempObject.ManyToOneList = new TestAbstractClass[] { new TestClass2(), new TestClass2(), new TestClass2() }.ToList(); TempObject.Map = new TestClass2(); TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestAbstractClass, int>(TempObject); Assert.Equal(true, TempObject.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, TempObject.ByteArrayReference); Assert.Equal(12, TempObject.ByteReference); Assert.Equal('v', TempObject.CharReference); Assert.Equal(1.4213m, TempObject.DecimalReference); Assert.Equal(1.32645d, TempObject.DoubleReference); Assert.Equal(TestEnum.Value2, TempObject.EnumReference); Assert.Equal(1234.5f, TempObject.FloatReference); Assert.Equal(TempGuid, TempObject.GuidReference); Assert.Equal(145145, TempObject.IntReference); Assert.Equal(763421, TempObject.LongReference); Assert.Equal(2, TempObject.ManyToManyIEnumerable.Count()); Assert.Equal(3, TempObject.ManyToManyList.Count); Assert.Equal(3, TempObject.ManyToOneIEnumerable.Count()); Assert.NotNull(TempObject.ManyToOneItem); Assert.Equal(3, TempObject.ManyToOneList.Count); Assert.NotNull(TempObject.Map); Assert.Equal(null, TempObject.NullStringReference); Assert.Equal(5423, TempObject.ShortReference); Assert.Equal("agsdpghasdg", TempObject.StringReference); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionWithAbstractClassTestDatabase;Integrated Security=SSPI;Pooling=false")); IList <dynamic> Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestAbstractClass_").Execute().First(); TestAbstractClass Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); Item.ByteArrayReference = new byte[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 110 }; Item.ByteReference = 121; Item.CharReference = 'V'; Item.DecimalReference = 11.4213m; Item.DoubleReference = 11.32645d; Item.EnumReference = TestEnum.Value3; Item.FloatReference = 14.5f; Item.IntReference = 1451445; Item.LongReference = 7634121; Item.ShortReference = 43; Item.StringReference = "Something"; TestObject.Save <TestAbstractClass, int>(Item); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionWithAbstractClassTestDatabase;Integrated Security=SSPI;Pooling=false")); Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestAbstractClass_").Execute().First(); Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 110 }, Item.ByteArrayReference); Assert.Equal(121, Item.ByteReference); Assert.Equal('V', Item.CharReference); Assert.Equal(11.4213m, Item.DecimalReference); Assert.Equal(11.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value3, Item.EnumReference); Assert.Equal(14.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(1451445, Item.IntReference); Assert.Equal(7634121, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(43, Item.ShortReference); Assert.Equal("Something", Item.StringReference); }
public void LargeBatchInsert() { Guid TempGuid = Guid.NewGuid(); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(TestDatabaseSource); for (int x = 0; x < 1000; ++x) { Temp.AddCommand(null, null, "insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", "Test String", 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid); } Temp.Execute(); }