Created
March 2, 2012 18:29
-
-
Save ioleksiy/1960224 to your computer and use it in GitHub Desktop.
AcroDB. Business Logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [AcroDbEntity] | |
| public interface IPage | |
| { | |
| Guid ID { get; set; } | |
| Guid? IDPageParent { get; set; } | |
| int Order { get; set; } | |
| [AcroColumnStringLength(50)] | |
| string Name { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The article http://www.oleksiy.pro/2010/04/13/acrodb-business-logic/