+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Dynamic Content, Linq and Joining on SystemParentId

Dynamic Content, Linq and Joining on SystemParentId

1 posts, 0 answered
  1. Merritt
    Merritt avatar
    31 posts
    Registered:
    11 Mar 2011
    18 Jul 2015
    Link to this post

    Gist Playground

    The rawest version of my problem is this:

     

    var manager = DynamicModuleManager.GetManager();
    var foo = from parent in manager.GetDataItems(<parent_content_type>)
              join child in manager.GetDataItems(<child_content_type>)
              on parent.Id equals child.SystemParentId
              select new { ProdId = pd.Id, PerfId = pf.Id };
     

    I need to join my parent types on child types because that's  just expected normal run of the mill behavior for any system. My parent type is called production. My child type is called peformance. I created them using Dynamic Module Builder. Your API for getting child items only works for single parent items, so that's not usable; here's my code:

    var foo = from pd in _productionManager.GetMasters()
              join pf in _performanceManager.GetMasters() on pd.Id equals pf.SystemParentId
              select new { ProdId = pd.Id, PerfDate = pf.GetValue<DateTime?>(PerformanceFieldNames.DateTime) };
     

    I created wrappers for DynamicModuleManager and created child classes for each impelmentation of a dynamic content i make. Anyways get masters just looks like this:

    public IQueryable<DynamicContent> GetMasters()
    {
        return DynamicModuleManager.GetDataItems(Type).Where(s => s.Status == ContentLifecycleStatus.Master);
    }
     

    The point is it won't let me join and throws and exception:

    No generic method 'Join' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic​

     My goal here is do nothing fancy, just this:

     

    var foo = from pd in _productionManager.GetMasters()
                          join pf in _performanceManager.GetMasters() on pd.Id equals pf.SystemParentId
                          select new { ProdId = pd.Id, PerfDate = pf.GetValue<DateTime?>(PerformanceFieldNames.DateTime) }
                              into j1
                              group j1 by j1.ProdId
                                  into g
                                  select new { ProdId = g.Key, PerfDateTime = g.Min(q => q.PerfDate) };

     

    Oh, and I do not want to have to use in-memory list of ids to handle this sort of thing; id rather just use a stored proc or something then.

     

1 posts, 0 answered