public void PopulateUsingKeys(string[] keys) {
            Id = int.Parse(keys.First());

            ms1 = Container.Instances<MostSimple>().Single(x => x.Id == 1);
            dt1 = Container.Instances<WithDateTimeKey>().FirstOrDefault();
            vm1 = Container.NewViewModel<MostSimpleViewModel>();
            vm1.Id = 1;
        }
示例#2
0
        public void PopulateUsingKeys(string[] keys)
        {
            Id = int.Parse(keys.First());

            ms1    = Container.Instances <MostSimple>().Single(x => x.Id == 1);
            dt1    = Container.Instances <WithDateTimeKey>().FirstOrDefault();
            vm1    = Container.NewViewModel <MostSimpleViewModel>();
            vm1.Id = 1;
        }
示例#3
0
        private static void SeedCodeFirstDatabase(CodeFirstContext context)
        {
            var ms1 = new MostSimple {
                Id = 1
            };
            var ms2 = new MostSimple {
                Id = 2
            };
            var ms3 = new MostSimple {
                Id = 4
            };

            context.MostSimples.Add(ms1);

            context.MostSimples.Add(ms2);

            context.MostSimples.Add(ms3);

            var wr1 = new WithReference {
                Id = 1, AReference = ms1, ADisabledReference = ms1, AChoicesReference = ms1, AnEagerReference = ms1, AnAutoCompleteReference = ms1
            };
            var wr2 = new WithReference {
                Id = 2, AReference = ms1, ADisabledReference = ms1, AChoicesReference = ms1, AnEagerReference = ms1, AnAutoCompleteReference = ms1
            };

            context.WithReferences.Add(wr1);

            context.WithReferences.Add(wr2);

            var wv1 = new WithValue {
                Id = 1, AValue = 100, ADisabledValue = 200, AStringValue = ""
            };

            context.WithValues.Add(wv1);

            var wv2 = new WithValue {
                Id = 2, AValue = 100, ADisabledValue = 200, AStringValue = ""
            };

            context.WithValues.Add(wv2);

            var ws1 = new WithScalars {
                Id        = 1,
                Bool      = true,
                Byte      = 1,
                ByteArray = new[] {
                    (byte)2
                },
                Char      = '3',
                CharArray = new[] {
                    (char)4
                },
                DateTime   = new DateTime(2012, 03, 27, 08, 42, 36, 0, DateTimeKind.Utc).ToUniversalTime(),
                Decimal    = 5.1M,
                Double     = 6.2,
                Float      = 7.3F,
                Int        = 8,
                Long       = 9L,
                SByte      = 10,
                SByteArray = new[] {
                    (sbyte)11
                },
                Short  = 12,
                String = "13",
                UInt   = 14,
                ULong  = 15,
                UShort = 16
            };

            context.WithScalarses.Add(ws1);

            var wa1 = new WithActionObject {
                Id = 1
            };

            context.WithActionObjects.Add(wa1);

            var wc1 = new WithCollection {
                Id = 1
            };

            wc1.ACollection.Add(ms1);
            wc1.ACollection.Add(ms2);
            wc1.ACollection.Add(ms3);
            wc1.ACollectionViewModels.Add(new MostSimpleViewModel {
                Id = 1
            });
            wc1.ACollectionViewModels.Add(new MostSimpleViewModel {
                Id = 2
            });
            wc1.ASet.Add(ms1);

            wc1.ASet.Add(ms2);

            wc1.ADisabledCollection.Add(ms1);
            wc1.ADisabledCollection.Add(ms2);
            wc1.AHiddenCollection.Add(ms1);
            wc1.AHiddenCollection.Add(ms2);
            wc1.AnEagerCollection.Add(ms1);
            wc1.AnEagerCollection.Add(ms2);
            context.WithCollections.Add(wc1);

            var we1 = new WithError {
                Id = 1
            };

            context.WithErrors.Add(we1);

            var we2 = new WithError {
                Id = 2
            };

            context.WithErrors.Add(we2);

            var we3 = new WithError {
                Id = 3
            };

            context.WithErrors.Add(we3);

            var we4 = new WithError {
                Id = 4
            };

            context.WithErrors.Add(we4);

            var wge1 = new WithGetError {
                Id = 1
            };

            context.WithGetErrors.Add(wge1);

            var i1 = new Immutable {
                Id = 1
            };

            context.Immutables.Add(i1);

            var vs1 = new VerySimple {
                Id = 1
            };

            context.VerySimples.Add(vs1);

            var vs2 = new VerySimple {
                Id = 2
            };

            context.VerySimples.Add(vs2);

            var vse1 = new VerySimpleEager {
                Id = 1
            };

            context.VerySimpleEagers.Add(vse1);

            var dt1 = new WithDateTimeKey {
                Id = (new DateTime(634835232000000000L)).Date
            };

            context.WithDateTimeKeys.Add(dt1);

            var rdo1 = new RedirectedObject {
                Id = 1, ServerName = "RedirectedToServer", Oid = "RedirectedToOid"
            };

            context.RedirectedObjects.Add(rdo1);

            var wat1 = new WithAttachments {
                Id = 1
            };

            context.WithAttachments.Add(wat1);

            int added = context.SaveChanges();

            wc1.ACollection.Remove(ms3);

            context.SaveChanges();
        }
            private static void SeedCodeFirstDatabase(CodeFirstContext context) {
                var ms1 = new MostSimple { Id = 1 };
                var ms2 = new MostSimple { Id = 2 };
                var ms3 = new MostSimple { Id = 4 };
                context.MostSimples.Add(ms1);

                context.MostSimples.Add(ms2);

                context.MostSimples.Add(ms3);

                var wr1 = new WithReference { Id = 1, AReference = ms1, ADisabledReference = ms1, AChoicesReference = ms1, AnEagerReference = ms1, AnAutoCompleteReference = ms1 };
                var wr2 = new WithReference { Id = 2, AReference = ms1, ADisabledReference = ms1, AChoicesReference = ms1, AnEagerReference = ms1, AnAutoCompleteReference = ms1 };
                context.WithReferences.Add(wr1);

                context.WithReferences.Add(wr2);

                var wv1 = new WithValue { Id = 1, AValue = 100, ADisabledValue = 200, AStringValue = "" };
                context.WithValues.Add(wv1);

                var wv2 = new WithValue { Id = 2, AValue = 100, ADisabledValue = 200, AStringValue = "" };
                context.WithValues.Add(wv2);

                var ws1 = new WithScalars {
                    Id = 1,
                    Bool = true,
                    Byte = 1,
                    ByteArray = new[] {
                    (byte) 2
                },
                    Char = '3',
                    CharArray = new[] {
                    (char) 4
                },
                    DateTime = new DateTime(2012, 03, 27, 08, 42, 36, 0, DateTimeKind.Utc).ToUniversalTime(),
                    Decimal = 5.1M,
                    Double = 6.2,
                    Float = 7.3F,
                    Int = 8,
                    Long = 9L,
                    SByte = 10,
                    SByteArray = new[] {
                    (sbyte) 11
                },
                    Short = 12,
                    String = "13",
                    UInt = 14,
                    ULong = 15,
                    UShort = 16
                };

                context.WithScalarses.Add(ws1);

                var wa1 = new WithActionObject { Id = 1 };
                context.WithActionObjects.Add(wa1);

                var wc1 = new WithCollection { Id = 1 };
                wc1.ACollection.Add(ms1);
                wc1.ACollection.Add(ms2);
                wc1.ACollection.Add(ms3);

                wc1.ASet.Add(ms1);

                wc1.ASet.Add(ms2);

                wc1.ADisabledCollection.Add(ms1);
                wc1.ADisabledCollection.Add(ms2);
                wc1.AHiddenCollection.Add(ms1);
                wc1.AHiddenCollection.Add(ms2);
                wc1.AnEagerCollection.Add(ms1);
                wc1.AnEagerCollection.Add(ms2);
                context.WithCollections.Add(wc1);

                var we1 = new WithError { Id = 1 };
                context.WithErrors.Add(we1);

                var we2 = new WithError { Id = 2 };
                context.WithErrors.Add(we2);

                var we3 = new WithError { Id = 3 };
                context.WithErrors.Add(we3);

                var we4 = new WithError { Id = 4 };
                context.WithErrors.Add(we4);

                var wge1 = new WithGetError { Id = 1 };
                context.WithGetErrors.Add(wge1);

                var i1 = new Immutable { Id = 1 };
                context.Immutables.Add(i1);

                var vs1 = new VerySimple { Id = 1 };
                context.VerySimples.Add(vs1);

                var vs2 = new VerySimple { Id = 2 };
                context.VerySimples.Add(vs2);

                var vse1 = new VerySimpleEager { Id = 1 };
                context.VerySimpleEagers.Add(vse1);

                var dt1 = new WithDateTimeKey { Id = (new DateTime(634835232000000000L)).Date };
                context.WithDateTimeKeys.Add(dt1);

                var rdo1 = new RedirectedObject { Id = 1, ServerName = "RedirectedToServer", Oid = "RedirectedToOid" };
                context.RedirectedObjects.Add(rdo1);

                var wat1 = new WithAttachments { Id = 1 };
                context.WithAttachments.Add(wat1);

                int added = context.SaveChanges();

                wc1.ACollection.Remove(ms3);

                context.SaveChanges();
            }