private async Task SetupDataAsync() { var TestObject = new SchemaManager(MappingManager, Configuration, Logger, DataModeler, Sherlock, Helper); var Session = Canister.Builder.Bootstrapper.Resolve <ISession>(); await Helper .CreateBatch() .AddQuery(CommandType.Text, "DELETE FROM ManyToManyProperties_") .AddQuery(CommandType.Text, "DELETE FROM ManyToManyPropertiesWithCascade_") .AddQuery(CommandType.Text, "DELETE FROM AllReferencesAndID_") .ExecuteScalarAsync <int>().ConfigureAwait(false); var InitialData = new ManyToManyProperties[] { new ManyToManyProperties { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, new ManyToManyProperties { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, new ManyToManyProperties { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, }; var InitialData2 = new ManyToManyPropertiesWithCascade[] { new ManyToManyPropertiesWithCascade { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, new ManyToManyPropertiesWithCascade { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, new ManyToManyPropertiesWithCascade { BoolValue = true, ManyToManyClass = new List <AllReferencesAndID>() { new AllReferencesAndID { BoolValue = true, ByteValue = 1, NullableBoolValue = true, CharValue = 'a', DateTimeValue = new DateTime(2008, 1, 1), DecimalValue = 13.2m, DoubleValue = 423.12341234, FloatValue = 1243.1f, GuidValue = Guid.Parse("ad0d39ad-6889-4ab3-965d-3d4042344ee6"), IntValue = 12, LongValue = 2, NullableByteValue = 1, SByteValue = 2, ShortValue = 1, StringValue1 = "asdfvzxcv", StringValue2 = "qwerertyizjgposgj", ULongValue = 12, UIntValue = 5342, UShortValue = 1234 } } }, }; await Session.Save(InitialData.SelectMany(x => x.ManyToManyClass).ToArray()).ExecuteAsync().ConfigureAwait(false); await Session.Save(InitialData).ExecuteAsync().ConfigureAwait(false); await Session.Save(InitialData2).ExecuteAsync().ConfigureAwait(false); }
public async Task InsertMultipleObjectsWithCascade() { var TestObject = Canister.Builder.Bootstrapper.Resolve <ISession>(); await TestObject.Delete(DbContext <ManyToManyPropertiesWithCascade> .CreateQuery().ToList().ToArray()).ExecuteAsync().ConfigureAwait(false); await TestObject.Delete(DbContext <AllReferencesAndID> .CreateQuery().ToList().ToArray()).ExecuteAsync().ConfigureAwait(false); await SetupDataAsync().ConfigureAwait(false); var Result1 = new ManyToManyPropertiesWithCascade { BoolValue = false }; Result1.ManyToManyClass.Add(new AllReferencesAndID { ByteArrayValue = new byte[] { 1, 2, 3, 4 }, ByteValue = 34, CharValue = 'a', DateTimeValue = new DateTime(2000, 1, 1) }); var Result2 = new ManyToManyPropertiesWithCascade { BoolValue = false }; Result2.ManyToManyClass.Add(new AllReferencesAndID { ByteArrayValue = new byte[] { 5, 6, 7, 8 }, ByteValue = 34, CharValue = 'b', DateTimeValue = new DateTime(2000, 1, 1) }); var Result3 = new ManyToManyPropertiesWithCascade { BoolValue = false }; Result3.ManyToManyClass.Add(new AllReferencesAndID { ByteArrayValue = new byte[] { 9, 10, 11, 12 }, ByteValue = 34, CharValue = 'c', DateTimeValue = new DateTime(2000, 1, 1) }); await TestObject.Save(Result1, Result2, Result3).ExecuteAsync().ConfigureAwait(false); var Results = await TestObject.ExecuteAsync <ManyToManyPropertiesWithCascade>("SELECT ID_ as [ID], BoolValue_ as [BoolValue] FROM ManyToManyPropertiesWithCascade_", CommandType.Text, "Default").ConfigureAwait(false); Assert.Equal(6, Results.Count()); Assert.Contains(Results, x => x.ID == Result1.ID && !x.BoolValue && x.ManyToManyClass.Count == 1 && x.ManyToManyClass.Any(y => y.ByteValue == 34 && y.CharValue == 'a' && y.DateTimeValue == new DateTime(2000, 1, 1))); Assert.Contains(Results, x => x.ID == Result2.ID && !x.BoolValue && x.ManyToManyClass.Count == 1 && x.ManyToManyClass.Any(y => y.ByteValue == 34 && y.CharValue == 'b' && y.DateTimeValue == new DateTime(2000, 1, 1))); Assert.Contains(Results, x => x.ID == Result3.ID && !x.BoolValue && x.ManyToManyClass.Count == 1 && x.ManyToManyClass.Any(y => y.ByteValue == 34 && y.CharValue == 'c' && y.DateTimeValue == new DateTime(2000, 1, 1))); await TestObject.Delete(DbContext <ManyToManyPropertiesWithCascade> .CreateQuery().ToList().ToArray()).ExecuteAsync().ConfigureAwait(false); await TestObject.Delete(DbContext <AllReferencesAndID> .CreateQuery().ToList().ToArray()).ExecuteAsync().ConfigureAwait(false); }