Skip to content

Instantly share code, notes, and snippets.

@ioleksiy
Created March 2, 2012 18:29
Show Gist options
  • Select an option

  • Save ioleksiy/1960224 to your computer and use it in GitHub Desktop.

Select an option

Save ioleksiy/1960224 to your computer and use it in GitHub Desktop.
AcroDB. Business Logic
[AcroDbEntity]
public interface IPage
{
Guid ID { get; set; }
Guid? IDPageParent { get; set; }
int Order { get; set; }
[AcroColumnStringLength(50)]
string Name { get; set; }
}
public static class ExtensionIPage
{
public static IPage GetParent(this IPage page)
{
return page.IDPageParent != null
? page.AcroContext().Provide<IPage>()
.Get(page.IDPageParent.Value)
: null;
}
public static void SetParent(this IPage page, IPage parent)
{
if (parent != null)
page.IDPageParent = parent.ID;
else
page.IDPageParent = null;
}
public static IList<IPage> GetChildren(this IPage page)
{
return page.AcroContext().Provide<IPage>()
.Query.Where(p => p.IDPageParent.Equals(page.ID))
.ToList();
}
}
using (var manager = AcroDataContext.Go)
{
var page = manager.Provide<IPage>()
.Query.Where(p => p.Name == "default").First();
if (page == null)
return;
foreach (var p in page.GetChildren())
{
Console.WriteLine(p.Name);
}
}
@ioleksiy
Copy link
Author

ioleksiy commented Mar 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment