Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows for the ability to strongly-type a list of child items #28

Closed
wants to merge 1 commit into from
Closed

Allows for the ability to strongly-type a list of child items #28

wants to merge 1 commit into from

Conversation

asmorger
Copy link
Contributor

Summary

Incorporated changes from an old Vault fork that allows for querying strongly-typed children based upon a base type.

Example

[UmbracoEntity]
public abstract class BaseItem
{
     public string Title { get; set;}
}

[UmbracoEntity]
public class RangeItem : BaseItem
{
     public int Start { get; set; }
     public int Stop { get; set; }
} 

[UmbracoEntity]
public class SpecialItem : BaseItem
{
     public string LookAtMeIAmSpecial { get; set; }
}

var children = Vault.Context.GetChildren<BaseItem>(0);

The children variable in this instance will then contain an array of either strongly-typed Range or Special Items, as determined by the individual item's Alias/DocType.

Reference

See feature request #22

Notes

  • There are some potentially bad practices in this code we may want to re-design, such as scanning all assemblies for all classes with an UmbracoEntity attribute.

@asmorger asmorger added this to the v1.3.0 milestone Apr 20, 2016
@asmorger
Copy link
Contributor Author

Note: This code was originally authored by @jaredswarts55. I cleaned it up a little, but it's mostly his.

@kensykora
Copy link
Contributor

Cool -- thinking this should be in a 2.0 release since potentially it changes behavior, what do you think?

@asmorger
Copy link
Contributor Author

As long as I can get an alpha build so we can incorporate into the projects that currently have it, I'm fine with that.

I know internally there are a number of individual forks that have implemented this at The Nerdery, so this would need to be a known dependency for them before we attempt to upgrade them off the forks and onto the Nuget package.

@kensykora kensykora modified the milestones: v2.0.0, v1.3.0 Apr 20, 2016
@kensykora
Copy link
Contributor

Merged into 2.0.0 branch. Going to rename a few things since this is not strictly specific to just getting child collections, and applies to getting individual items. Will change the default behavior to NOT do this to integrate into the next 1.3 release.

@kensykora kensykora closed this Apr 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants