x First time here? Check out the FAQ
  • Avatar12posts32karma

    'Export to .net' not including properties on inherited tabs.

    Rich started this topic More than a year ago , this topic was edited at: Sunday, August 21, 2011 4:50 PM

    When trying to access a property on my doc type using Linq2Umbraco, I noticed that some of the properties were missing.

    Sad times.

    On investigating, I noticed that all the properties that were missing were on the same 'inherited' tab (from it's parent doc type). I moved the properties to a new temporary tab just to see if it made a difference and sure enough, they all exported fine.

    My sneaky suspicion is that this is somewhat related to any work that went on regarding the following post:

    our.umbraco.org/.../11619-LINQ-2-Umbraco-expected-export-behavior

    Just wanted to see what people's opinions were and as to whether it's worth investigating a fix.

    Thanks,
    Rich 


  • Replies

  • Avatar2163posts2557karma
    Comment with ID: 70710
    Ismail Mayat posted this reply More than a year ago

    Rich,

    I have been using our.umbraco.org/.../autoexport2dotnet and have had no issues with inherited properties

    Regards

    Ismail


  • Thomas posted this reply 9 months ago

    Yes seeing the exact same issue in v.4.7, issue occurs with our without using the autoexport2dotnet (our.umbraco.org/.../autoexport2dotnet) - so seems an issue in the core export logic.

    Place a property of any type in the Generic tab and it always exports, move it to a tab inherited from the parent docType and it's excluded from the export.

    This is caused by what seems like a bug in the umbraco.presentation project, in \umbraco\presentation\umbraco\dialogs\ExportCode.aspx.cs in the GenerateProperties method.

    private object GenerateProperties(DocumentType dt)
    {
    var sb = new StringBuilder();

    foreach (var pt in
    dt.getVirtualTabs.Where(x => x.ContentType == dt.Id).SelectMany(x => x.GetPropertyTypes(dt.Id, true))
    .Concat(dt.PropertyTypes.Where(x => x.ContentTypeId == dt.Id /* don't limit this to generic tab! && x.TabId == 0*/))
    )
    {
    //...loops and writes properties here

    In the above the bit to remove is the "x.TabId == 0" that I've commented out - this limits the properties rendered to the first tab (the generic properties).

    I have only tested this quickly, but seems to work perfectly - I will update here if I find any issues - cheers!

    PS. Please note that this method has changed between version 4.7.0 and 4.7.1 because of a separate issue - however for both version removing the "x.TabId == 0" solves this issue.


  • Avatar1472posts2342karma
    Comment with ID: 86754
    Tom Fulton posted this reply 9 months ago

    Hi Thomas,

    Thanks for sharing the fix.  I think you should also post this on Codeplex so one of the devs might see it and update it in the core as well :)

    -Tom


  • Thomas posted this reply 9 months ago

    Good point - that's here if anyone wants to vote: http://umbraco.codeplex.com/workitem/30419

     


  • Thomas posted this reply 9 months ago

    Slight amend - need a distinct on the end, otherwise anything actually sitting in the "generic properties" tab gets duplicated:

     

    		private object GenerateProperties(DocumentType dt)
    {
    var sb = new StringBuilder();

    foreach (var pt in
    dt.getVirtualTabs.Where(x => x.ContentType == dt.Id).SelectMany(x => x.GetPropertyTypes(dt.Id, true))
    .Concat(dt.PropertyTypes.Where(x => x.ContentTypeId == dt.Id /* don't limit this to generic tab! && x.TabId == 0*/)).Distinct()
    )
    {
    //...loops and writes properties here

  • Thomas posted this reply 9 months ago

    Further to the above, if you include abstractions (interfaces) in your export - the above amend also need to be done in the GenerateAbstractProperties method - so remove the TabID == 0 check, and add a Distinct() to the end.


Please login or Sign up To post replies