public void InsertFirstChild() { var id = SqlHierarchyId.GetRoot(); var idChild = id.GetDescendant(SqlHierarchyId.Null, SqlHierarchyId.Null); Assert.AreEqual(id, idChild.GetAncestor(1)); }
public void GetParentOfRootNode() { var root = SqlHierarchyId.GetRoot(); var parent = root.GetAncestor(1); Assert.IsTrue(parent.IsNull); }
public void InsertTopLevelNodeBetweenNodes() { var id = SqlHierarchyId.GetRoot(); var idChild = id.GetDescendant(SqlHierarchyId.Parse("/0/"), SqlHierarchyId.Parse("/1/")); Assert.AreEqual("/0.1/", idChild.ToString()); }
public void TestHierarchyId([IncludeDataSources(true, TestProvName.AllSqlServer2008Plus)] string context) { #if NETCOREAPP2_1 if (IsMsProvider(context)) { Assert.Inconclusive("Spatial types test disabled for Microsoft.Data.SqlClient"); } #endif using (new SerializeAssemblyQualifiedName(true)) using (var conn = GetDataContext(context)) { conn.GetTable <AllTypes2>() .Where(t => (bool)(t.hierarchyidDataType.GetLevel() > 0)) .Select(t => new { v1 = SqlHierarchyId.GetRoot(), v2 = Sql.ToSql(t.hierarchyidDataType.GetDescendant(SqlHierarchyId.Parse("/1/3/4/"), SqlHierarchyId.Parse("/1/3/5/"))), v3 = t.hierarchyidDataType.IsDescendantOf(SqlHierarchyId.Parse("/1/")), v4 = t.hierarchyidDataType.GetLevel(), v5 = t.hierarchyidDataType.GetAncestor(0), v6 = t.hierarchyidDataType.GetReparentedValue(SqlHierarchyId.Parse("/1/"), SqlHierarchyId.Parse("/2/")), v7 = SqlHierarchyId.Parse("/1/2/3/4/5/"), v8 = t.hierarchyidDataType.ToString(), }) .ToList(); } }
private int CreateDirectory( string directoryPath, out SqlHierarchyId parentNode) { parentNode = SqlHierarchyId.GetRoot(); var documentLevel = 0; if (string.IsNullOrEmpty(directoryPath)) { return(documentLevel); } var directoryParts = directoryPath.Split(Path.DirectorySeparatorChar); var newDirectory = false; foreach (var directoryPart in directoryParts) { var document = CreateDirectory(directoryPart, documentLevel, parentNode, ref newDirectory); parentNode = document.DocumentNode ?? SqlHierarchyId.GetRoot(); documentLevel++; } return(documentLevel); }
public static SqlHierarchyId NextLabelNode() { var max = Database.Query <LabelEntity>() .Where(lab => (bool)(lab.Node.GetAncestor(1) == SqlHierarchyId.GetRoot())) .Select(lab => lab.Node) .ToList() .Max(a => (SqlHierarchyId?)a) ?? SqlHierarchyId.Null; return(SqlHierarchyId.GetRoot().GetDescendant(max, SqlHierarchyId.Null)); }
public Boolean RootExists() { try { byte[] bRoot = Conversions.HierarchyId2Bytes(SqlHierarchyId.GetRoot()); long nr = repo.Get.Where(p => p.hid == bRoot).Count(); return(nr > 0); } catch (Exception ex) { throw new Exception("Erro ao verificar root: " + ex.Message); } }
public byte[] GetNextSonHid(String mae) // Obtém hid do próximo novo filho { byte[] b = null; try { // obter hid da mãe if (string.IsNullOrEmpty(mae)) { b = Conversions.HierarchyId2Bytes(SqlHierarchyId.GetRoot()); } else { SqlHierarchyId maeHid = Conversions.Bytes2HierarchyId(repo.Find(new object[] { long.Parse(mae) }).hid); long m = long.Parse(mae); // byte[] LastChildHid = null; // = repo.Get.Where(p => p.Parent == m).Select(p => p.hid).Max(); SqlHierarchyId lastChHid = SqlHierarchyId.Null; foreach (T r in repo.Get) { SqlHierarchyId h = Conversions.Bytes2HierarchyId(r.hid); if (h.GetAncestor(1) == maeHid) { if (lastChHid.IsNull || h > lastChHid) { lastChHid = h; } } } if (lastChHid == SqlHierarchyId.Null) { b = Conversions.HierarchyId2Bytes(maeHid.GetDescendant(SqlHierarchyId.Null, SqlHierarchyId.Null)); } else { b = Conversions.HierarchyId2Bytes(maeHid.GetDescendant(lastChHid, SqlHierarchyId.Null)); } } } catch (Exception ex) { throw new Exception("Erro em GetNextSonHid: " + ex.Message); } return(b); }
public static SqlHierarchyId CalculateRoute <T>(T t) where T : TreeEntity, new() { if (!t.IsSibling) { if (t.ParentOrSibling == null) { return(SqlHierarchyId.GetRoot().GetDescendant(LastChild <T>(SqlHierarchyId.GetRoot()), SqlHierarchyId.Null)); } var parentRoute = t.ParentOrSibling.InDB(p => p.Route); return(parentRoute.GetDescendant(LastChild <T>(parentRoute), SqlHierarchyId.Null)); } else { var siblingRoute = t.ParentOrSibling !.InDB(p => p.Route); return(siblingRoute.GetAncestor(1).GetDescendant(siblingRoute, Next <T>(siblingRoute))); } }
public void SqlHierarchyIdFunction() { if (!Schema.Current.Settings.UdtSqlName.ContainsKey(typeof(SqlHierarchyId))) { return; } var nodes = Database.Query <LabelEntity>().Select(a => a.Node); Debug.WriteLine(nodes.Select(n => n.GetAncestor(0).InSql()).ToString(", ")); Debug.WriteLine(nodes.Select(n => n.GetAncestor(1).InSql()).ToString(", ")); Debug.WriteLine(nodes.Select(n => (int)(short)n.GetLevel().InSql()).ToString(", ")); Debug.WriteLine(nodes.Select(n => n.ToString().InSql()).ToString(", ")); Debug.WriteLine(nodes.Where(n => (bool)(n.GetDescendant(null, null) > SqlHierarchyId.GetRoot())).ToString(", ")); Debug.WriteLine(nodes.Where(n => (bool)(n.GetReparentedValue(n.GetAncestor(0), SqlHierarchyId.GetRoot()) > SqlHierarchyId.GetRoot())).ToString(", ")); }
public byte[] GetNextSonHid(String mae) // Obtém hid do próximo novo filho { byte[] b = null; try { // obter hid da mãe if (string.IsNullOrEmpty(mae)) { b = Conversions.HierarchyId2Bytes(SqlHierarchyId.GetRoot()); } else { string command = "DECLARE @last_child hierarchyid, @maeId as hierarchyid, @mae as bigint " + Environment.NewLine + " SET TRANSACTION ISOLATION LEVEL SERIALIZABLE " + Environment.NewLine + " BEGIN TRANSACTION" + Environment.NewLine + " set @mae = " + (mae == null ? " null" : mae) + Environment.NewLine + " declare @hid as hierarchyid" + Environment.NewLine + " if @mae is null" + Environment.NewLine + " set @maeID = null"+ Environment.NewLine + " Else" + Environment.NewLine + " begin" + Environment.NewLine + " select @maeId = cast(hid as hierarchyid) from "+ TableName + " where " + PKName + " = @mae" + Environment.NewLine + " End" + Environment.NewLine + " if @maeID is null" + Environment.NewLine + " set @hid = hierarchyid::GetRoot() "+ Environment.NewLine + " Else" + Environment.NewLine + " begin" + Environment.NewLine + " select @last_child = cast(MAX(hid) as hierarchyid) from "+ TableName + " where cast(hid as hierarchyid).GetAncestor(1) = @maeId" + Environment.NewLine + " set @hid = @maeID.GetDescendant(@last_child,NULL)"+ Environment.NewLine + " End" + Environment.NewLine + " select cast(@hid as varbinary) as hid " + Environment.NewLine + " COMMIT"; var result = db.Database.SqlQuery <byte[]>(command).ToList(); b = result.SelectMany(a => a).ToArray(); } } catch (Exception ex) { throw new Exception("Erro em GetNextSonHid: " + ex.Message); } return(b); }
public void TestHierarchyId(string context) { using (var conn = GetDataContext(context)) { conn.GetTable <AllTypes2>() .Where(t => (bool)(t.hierarchyidDataType.GetLevel() > 0)) .Select(t => new { v1 = SqlHierarchyId.GetRoot(), v2 = Sql.ToSql(t.hierarchyidDataType.GetDescendant(SqlHierarchyId.Parse("/1/3/4/"), SqlHierarchyId.Parse("/1/3/5/"))), v3 = t.hierarchyidDataType.IsDescendantOf(SqlHierarchyId.Parse("/1/")), v4 = t.hierarchyidDataType.GetLevel(), v5 = t.hierarchyidDataType.GetAncestor(0), v6 = t.hierarchyidDataType.GetReparentedValue(SqlHierarchyId.Parse("/1/"), SqlHierarchyId.Parse("/2/")), v7 = SqlHierarchyId.Parse("/1/2/3/4/5/"), v8 = t.hierarchyidDataType.ToString(), }) .ToList(); } }
private static SqlHierarchyId GetNewPosition <T>(MoveTreeModel model, TreeEntity entity) where T : TreeEntity { var newParentRoute = model.NewParent == null?SqlHierarchyId.GetRoot() : model.NewParent.InDB(a => a.Route); if (newParentRoute.IsDescendantOf(entity.Route)) { throw new Exception(TreeMessage.ImpossibleToMove0InsideOf1.NiceToString(entity, model.NewParent)); } if (model.InsertPlace == InsertPlace.FirstNode) { return(newParentRoute.GetDescendant(SqlHierarchyId.Null, FirstChild <T>(newParentRoute))); } if (model.InsertPlace == InsertPlace.LastNode) { return(newParentRoute.GetDescendant(LastChild <T>(newParentRoute), SqlHierarchyId.Null)); } var newSiblingRoute = model.Sibling !.InDB(a => a.Route); if (!newSiblingRoute.IsDescendantOf(newParentRoute) || newSiblingRoute.GetLevel() != newParentRoute.GetLevel() + 1 || newSiblingRoute == entity.Route) { throw new Exception(TreeMessage.ImpossibleToMove01Of2.NiceToString(entity, model.InsertPlace.NiceToString(), model.NewParent)); } if (model.InsertPlace == InsertPlace.After) { return(newParentRoute.GetDescendant(newSiblingRoute, Next <T>(newSiblingRoute))); } if (model.InsertPlace == InsertPlace.Before) { return(newParentRoute.GetDescendant(Previous <T>(newSiblingRoute), newSiblingRoute)); } throw new InvalidOperationException("Unexpected InsertPlace " + model.InsertPlace); }
public void RootIsNotNull() { Assert.AreNotEqual(SqlHierarchyId.GetRoot(), SqlHierarchyId.Null); }
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), 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), 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), Text = "Death on June, 25th", Target = michael } .Execute(NoteWithDateOperation.Save); new NoteWithDateEntity { CreationTime = new DateTime(2000, 1, 1, 0, 0, 0), Text = null, Target = michael } .SetMixin((CorruptMixin c) => c.Corrupt, true) .Do(n => n.Mixin <ColaboratorsMixin>().Colaborators.Add(michael)) .Execute(NoteWithDateOperation.Save); LabelEntity universal = new LabelEntity { Name = "UMG Recordings", Country = usa, Node = virgin.Node.NextSibling() } .Execute(LabelOperation.Save); new AlbumEntity { Name = "Ben", Year = 1972, Author = michael, Songs = { new SongEmbedded { Name = "Ben" } }, BonusTrack = new SongEmbedded { Name = "Michael" }, Label = universal, }.Execute(AlbumOperation.Save); LabelEntity sony = new LabelEntity { Name = "Sony", Country = japan, Node = universal.Node.NextSibling() } .Execute(LabelOperation.Save); new AlbumEntity { Name = "Thriller", Year = 1982, Author = michael, Songs = "Wanna Be Startin' Somethin', Thriller, Beat It" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), BonusTrack = new SongEmbedded { Name = "Billie Jean" }, Label = sony }.Execute(AlbumOperation.Save); LabelEntity mjj = new LabelEntity { Name = "MJJ", Country = usa, Owner = sony.ToLite(), Node = sony.Node.FirstChild() } .Execute(LabelOperation.Save); new AlbumEntity { Name = "Bad", Year = 1989, Author = michael, Songs = "Bad, Man in the Mirror, Dirty Diana, Smooth Criminal" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), Label = mjj }.Execute(AlbumOperation.Save); new AlbumEntity { Name = "Dangerous", Year = 1991, Author = michael, Songs = "Black or White, Who Is It, Give it to Me" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), Label = mjj }.Execute(AlbumOperation.Save); new AlbumEntity { Name = "HIStory", Year = 1995, Author = michael, Songs = "Billie Jean, Stranger In Moscow" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), BonusTrack = new SongEmbedded { Name = "Heal The World" }, Label = mjj }.Execute(AlbumOperation.Save); new AlbumEntity { Name = "Blood on the Dance Floor", Year = 1995, Author = michael, Songs = "Blood on the Dance Floor, Morphine" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), Label = mjj }.Execute(AlbumOperation.Save);; var ga = (GrammyAwardEntity) new GrammyAwardEntity { Category = "Foreing Band", Year = 2001, Result = AwardResult.Won } .Execute(AwardOperation.Save); BandEntity sigurRos = new BandEntity { Name = "Sigur Ros", Members = "Jón Þór Birgisson, Georg Hólm, Orri Páll Dýrason" .Split(',').Select(s => new ArtistEntity { Name = s.Trim() }.Execute(ArtistOperation.Save)).ToMList(), LastAward = ga, }.Execute(BandOperation.Save); LabelEntity fatCat = new LabelEntity { Name = "FatCat Records", Country = usa, Owner = universal.ToLite(), Node = universal.Node.FirstChild() } .Execute(LabelOperation.Save); new AlbumEntity { Name = "Ágaetis byrjun", Year = 1999, Author = sigurRos, Songs = "Scefn-g-englar" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), BonusTrack = new SongEmbedded { Name = "Intro" }, Label = fatCat, }.Execute(AlbumOperation.Save); LabelEntity emi = new LabelEntity { Name = "EMI", Country = usa, Node = sony.Node.NextSibling() }.Execute(LabelOperation.Save); new AlbumEntity { Name = "Takk...", Year = 2005, Author = sigurRos, Songs = "Hoppípolla, Glósóli, Saeglópur" .Split(',').Select(s => new SongEmbedded { Name = s.Trim() }).ToMList(), BonusTrack = new SongEmbedded { Name = "Svo hljótt" }, Label = emi }.Execute(AlbumOperation.Save); new AwardNominationEntity { Author = sigurRos.ToLite(), Award = ga.ToLite() }.Save(); new AwardNominationEntity { Author = michael.ToLite(), Award = ga.ToLite() }.Save(); new AwardNominationEntity { Author = smashingPumpkins.ToLite(), Award = ga.ToLite() }.Save(); new AwardNominationEntity { Author = sigurRos.ToLite(), Award = ama.ToLite() }.Save(); new AwardNominationEntity { Author = michael.ToLite(), Award = ama.ToLite() }.Save(); new AwardNominationEntity { Author = smashingPumpkins.ToLite(), Award = ama.ToLite() }.Save(); new AwardNominationEntity { Author = michael.ToLite(), Award = pa.ToLite() }.Save(); new AwardNominationEntity { Author = michael.ToLite(), Award = null }.Save(); new ConfigEntity { EmbeddedConfig = new EmbeddedConfigEmbedded { Awards = { ga.ToLite() } } }.Execute(ConfigOperation.Save); }
public void ThrowsOnNegativeAncestor() { var root = SqlHierarchyId.GetRoot(); var parent = root.GetAncestor(-1); }
public static HierarchyId GetRoot() => new HierarchyId(SqlHierarchyId.GetRoot());
private async Task <AccountHierarchy> AddToParent(AccountHierarchy entity, long?parentId, bool autoCommit = true) { if (!parentId.HasValue) { SqlHierarchyId parentLevel = SqlHierarchyId.GetRoot(); entity.ParentId = null; entity.UplinkId = null; entity.LevelPath = parentLevel.ToString(); } else { var parent = await _dbContext.AccountHierarchies.Where(x => x.Id == parentId) .Include(x => x.Children) .FirstOrDefaultAsync(); SqlHierarchyId parentLevel = SqlHierarchyId.Parse(parent.LevelPath); var lastSibling = parent.Children.OrderByDescending(x => x.LevelPath).FirstOrDefault(); string levelPath = null; if (entity.Leg == 2) { if (lastSibling == null) { levelPath = parent.LevelPath + "2/"; } else { SqlHierarchyId newLevel = parentLevel.GetDescendant(SqlHierarchyId.Parse(lastSibling.LevelPath), SqlHierarchyId.Null); levelPath = newLevel.ToString(); } } else if (entity.Leg == 1) // in any other case - put it on the left { if (lastSibling == null) { levelPath = parent.LevelPath + "1/"; } else { SqlHierarchyId newLevel = parentLevel.GetDescendant(SqlHierarchyId.Null, SqlHierarchyId.Parse(lastSibling.LevelPath)); levelPath = newLevel.ToString(); } } else { throw new ArgumentOutOfRangeException("Leg", "Invalid value for leg: " + entity.Leg); } entity.LevelPath = levelPath; entity.ParentId = parentId; } var result = (await _dbContext.AccountHierarchies.AddAsync(entity)).Entity; if (autoCommit) { await _dbContext.SaveChangesAsync(); } return(result); }
public void RootIsNotNull2() { Assert.IsFalse(SqlHierarchyId.GetRoot().IsNull); }
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 = (Date)DateTime.Now.AddHours(+8), 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 = (Date)DateTime.Now.AddDays(-100).AddHours(-8), 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 Date(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 Date(2000, 1, 1), Text = null !, Target = michael }