Skip to content

tawman/PetaPocoHierarchy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PetaPocoHierarchy Example

This sample project is meant to demonstrate how PetaPoco can load Hierarchical table data into a single POCO object while retaining the parent-child relationship.

Example Source Data

Id ParentId OrganizationCode Name
1 NULL US United States
2 1 MW Midwest
3 1 NE Northeast
4 1 NW Northwest
5 1 SE Southeast
6 1 SW Southwest
7 2 MI Michigan
8 2 IN Indiana
9 2 IL Illinois
10 2 OH Ohio
11 7 WC Wayne
12 7 WA Washtenaw
13 11 DE Detroit
14 11 CA Canton
15 11 PM Plymouth
16 12 AA Ann Arbor
17 12 YP Ypsilanti
18 16 UM University of Michigan
19 17 EMU Eastern Michigan University

Sample Data Loaded as POCO Objects by PetaPoco

Hierarchy Name Code
United States United States US
United States > Midwest Midwest MW
United States > Midwest > Illinois Illinois IL
United States > Midwest > Indiana Indiana IN
United States > Midwest > Michigan Michigan MI
United States > Midwest > Michigan > Washtenaw Washtenaw WA
United States > Midwest > Michigan > Washtenaw > Ann Arbor Ann Arbor AA
United States > Midwest > Michigan > Washtenaw > Ann Arbor > University of Michigan University of Michigan UM
United States > Midwest > Michigan > Washtenaw > Ypsilanti Ypsilanti YP
United States > Midwest > Michigan > Washtenaw > Ypsilanti > Eastern Michigan University Eastern Michigan University EMU
United States > Midwest > Michigan > Wayne Wayne WC
United States > Midwest > Michigan > Wayne > Canton Canton CA
United States > Midwest > Michigan > Wayne > Detroit Detroit DE
United States > Midwest > Michigan > Wayne > Plymouth Plymouth PM
United States > Midwest > Ohio Ohio OH
United States > Northeast Northeast NE
United States > Northwest Northwest NW
United States > Southeast Southeast SE
United States > Southwest Southwest SW

How To Build It?

From a command window run: build.bat

Otherwise, open the Solution file in Visual Studio 2010 and Build

How Do You View It?

From the Start menu, click Run, then type inetmgr to open the Internet Information Services (IIS) MMC snap-in.

  1. Right mouse click on the Default Web Site and Select "Add Application"
  2. Enter an Alias for the Site (i.e. PetaPocoHierarchy)
  3. Enter the Physical Path (i.e. C:@WCP\clone\PetaPocoHierarchy\src\PetaPocoHierarchy)
  4. Open a web browser to: http://localhost/PetaPocoHierarchy/

Alternatively, Open the PetaPocoHierarchy.sln Solution in Visual Studio 2010 and explore.

The sample database file provided was created with SQL Server 2008 R2. The SQL needed to create the table and populate the sample data is provided in the src/database directory.

Thanks

This software is Open Source and check the LICENSE.txt file for more details.

Todd A. Wood (@iToddWood) Visit Implement IToddWood