Skip to content

Commit

Permalink
Merge pull request n2cms#45 from GrimaceOfDespair/perfopt-grimace
Browse files Browse the repository at this point in the history
Perfopt grimace
  • Loading branch information
libardo committed Apr 25, 2012
2 parents e9e056f + f35891b commit 6cf9efc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using N2.Persistence;
using N2.Persistence.Search;
using N2.Details;
using N2.Definitions;
Expand Down Expand Up @@ -48,7 +50,11 @@ public virtual ContentItem LinkProperty
get { return (ContentItem)GetDetail("LinkProperty"); }
set { SetDetail<ContentItem>("LinkProperty", value); }
}
public virtual object ObjectProperty

[Editable(Name = "ContentLinks", PersistAs = PropertyPersistenceLocation.DetailCollection)]
public virtual IEnumerable<ContentItem> ContentLinks { get; set; }

public virtual object ObjectProperty
{
get { return (object)GetDetail("ObjectProperty"); }
set { SetDetail<object>("ObjectProperty", value); }
Expand Down
15 changes: 15 additions & 0 deletions src/Framework/Tests/Persistence/NH/PersisterLinksTests.cs
Expand Up @@ -166,5 +166,20 @@ public void Delete_ParentOf_ReferencedItem_ReferencedByDetailCollection_DeletesR
Assert.That(from.GetDetailCollection("References", true).Count, Is.EqualTo(0));
}
}

[Test]
public void SaveItem_WithReferences_DoesNotThrowSerializationException()
{
Definitions.PersistableItem1 parent, to, from;
using (persister)
{
parent = CreateOneItem<Definitions.PersistableItem1>(0, "parent", null);
to = CreateOneItem<Definitions.PersistableItem1>(0, "to", parent);
persister.Save(parent);
from = CreateOneItem<Definitions.PersistableItem1>(0, "from", null);
from.ContentLinks = new[] {to};
persister.Save(from);
}
}
}
}

0 comments on commit 6cf9efc

Please sign in to comment.