Exemplo n.º 1
0
        public void UpdateFieToLite()
        {
            using (Transaction tr = new Transaction())
            {
                LabelEntity label = Database.Query <LabelEntity>().FirstEx();

                int count = Database.Query <LabelEntity>().UnsafeUpdate()
                            .Set(a => a.Owner, a => label.ToLite())
                            .Execute();
                //tr.Commit();
            }
        }
Exemplo n.º 2
0
    public static void Load()
    {
        var ama = new AmericanMusicAwardEntity {
            Category = "Indie Rock", Year = 1991, Result = AwardResult.Nominated
        }
        .Execute(AwardOperation.Save);

        BandEntity smashingPumpkins = new BandEntity
        {
            Name    = "Smashing Pumpkins",
            Members = "Billy Corgan, James Iha, D'arcy Wretzky, Jimmy Chamberlin"
                      .Split(',').Select(s => new ArtistEntity {
                Name = s.Trim(), Sex = s.Contains("Wretzky") ? Sex.Female : Sex.Male, Status = s.Contains("Wretzky") ? Status.Married : (Status?)null
            }).ToMList(),
            LastAward = ama,
        }.Execute(BandOperation.Save);

        CountryEntity usa = new CountryEntity {
            Name = "USA"
        };
        CountryEntity japan = new CountryEntity {
            Name = Japan
        };

        smashingPumpkins.Members.ForEach(m => m.Friends = smashingPumpkins.Members.Where(a => a.Sex != m.Sex).Select(a => a.ToLiteFat()).ToMList());

        smashingPumpkins.Execute(BandOperation.Save);

        new NoteWithDateEntity {
            CreationTime = DateTime.Now.AddHours(+8), CreationDate = DateTime.Now.AddHours(+8).ToDateOnly(), Text = "American alternative rock band", Target = smashingPumpkins
        }
        .Execute(NoteWithDateOperation.Save);

        LabelEntity virgin = new LabelEntity {
            Name = "Virgin", Country = usa, Node = SqlHierarchyId.GetRoot().FirstChild()
        }
        .Execute(LabelOperation.Save);

        new AlbumEntity
        {
            Name   = "Siamese Dream",
            Year   = 1993,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "Disarm"
                       } },
            Label = virgin
        }.Execute(AlbumOperation.Save);

        AlbumEntity mellon = new AlbumEntity
        {
            Name   = "Mellon Collie and the Infinite Sadness",
            Year   = 1995,
            Author = smashingPumpkins,
            Songs  =
            {
                new SongEmbedded {
                    Name = "Zero", Duration = TimeSpan.FromSeconds(123)
                },
                new SongEmbedded {
                    Name = "1976"
                },
                new SongEmbedded {
                    Name = "Tonight, Tonight", Duration = TimeSpan.FromSeconds(376)
                }
            },
            BonusTrack = new SongEmbedded {
                Name = "Jellybelly"
            },
            Label = virgin
        }.Execute(AlbumOperation.Save);

        new NoteWithDateEntity {
            CreationTime = DateTime.Now.AddDays(-100).AddHours(-8), CreationDate = DateTime.Now.AddDays(-100).AddHours(-8).ToDateOnly(), Text = "The blue one with the angel", Target = mellon
        }
        .Execute(NoteWithDateOperation.Save);

        LabelEntity wea = new LabelEntity {
            Name = "WEA International", Country = usa, Owner = virgin.ToLite(), Node = virgin.Node.FirstChild()
        }
        .Execute(LabelOperation.Save);

        new AlbumEntity
        {
            Name   = "Zeitgeist",
            Year   = 2007,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "Tarantula"
                       } },
            BonusTrack = new SongEmbedded {
                Name = "1976"
            },
            Label = wea,
        }.Execute(AlbumOperation.Save);

        new AlbumEntity
        {
            Name   = "American Gothic",
            Year   = 2008,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "The Rose March", Duration = TimeSpan.FromSeconds(276)
                       } },
            Label = wea,
        }.Execute(AlbumOperation.Save);

        var pa = new PersonalAwardEntity {
            Category = "Best Artist", Year = 1983, Result = AwardResult.Won
        }.Execute(AwardOperation.Save);

        ArtistEntity michael  = new ArtistEntity
        {
            Name      = "Michael Jackson",
            Dead      = true,
            LastAward = pa,
            Status    = Status.Single,
            Friends   = { smashingPumpkins.Members.SingleEx(a => a.Name.Contains("Billy Corgan")).ToLite() }
        }.Execute(ArtistOperation.Save);;

        new NoteWithDateEntity {
            CreationTime = new DateTime(2009, 6, 25, 0, 0, 0), CreationDate = new DateOnly(2009, 6, 25), Text = "Death on June, 25th", Target = michael
        }
        .Execute(NoteWithDateOperation.Save);

        new NoteWithDateEntity {
            CreationTime = new DateTime(2000, 1, 1, 0, 0, 0), CreationDate = new DateOnly(2000, 1, 1), Text = null !, Target = michael
        }