Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luke 110 posts 256 karma points
    Mar 16, 2016 @ 13:51
    Luke
    1

    IContent By Document Type

    Hi All,

    What is most efficient way of getting IEnumerable

    Something similar to:

    IEnumerable<IContent> all = this.GetContentService().GetAll() all.Where(x => x.ContentType.Alias.Equals(DocType));
    

    Regards, L

  • Greg Fyans 140 posts 342 karma points
    Mar 16, 2016 @ 13:58
    Greg Fyans
    5

    If you already know your DocType ID, you can do this:

    IContentService cs = ApplicationContext.Current.Services.ContentService;
    IEnumerable<IContent> content = cs.GetContentOfContentType(1224);
    

    If you don't then you can get your content type from the content type service:

    IContentService cs = ApplicationContext.Current.Services.ContentService;
    IContentTypeService cts = ApplicationContext.Current.Services.ContentTypeService;
    IContentType ct = cts.GetContentType("docTypeAlias");
    IEnumerable<IContent> content = cs.GetContentOfContentType(ct.Id);
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies